简体   繁体   English

进入JSP页面后如何直接进入Servlet?

[英]How can I enter a Servlet right after entering the JSP page?

How can I enter a Servlet right after entering the JSP page?进入JSP页面后如何直接进入Servlet? Is it possible to get the requested parameters in the current page after entering the Servlet?进入Servlet后是否可以在当前页面获取请求的参数? After clicking an anchor tag, I want to get information using Servlet to my current JSP file.单击锚标记后,我想使用 Servlet 获取信息到我当前的 JSP 文件。 How do I that?我怎么办? What do I have to add in my anchor tag before going to my desired page?在转到我想要的页面之前,我必须在我的锚标记中添加什么?

Current page - Profile.jsp当前页面 - Profile.jsp

<a href="Profile.jsp">View Profile</a>    
<a href="ReportGeneration.jsp">View Report Generation</a>
<a href="Contact.jsp">Contact Us</a>

Desired page - ReportGeneration.jsp Servlet - ReportProcess.java所需页面 - ReportGeneration.jsp Servlet - ReportProcess.java

I want to print the information from ReportProcess servlet to ReportGeneration.jsp when "View Report Generation" tag is clicked.当单击“查看报告生成”标签时,我想将 ReportProcess servlet 中的信息打印到 ReportGeneration.jsp。

Include the servlet result into the ReportGeneration.jsp like this像这样将 servlet 结果包含到 ReportGeneration.jsp 中

<jsp:include page="/ReportProcess" /> 

here ReportProcess consider as a servlet URL in this area you will get the servlet output in this tag area这里 ReportProcess 认为是这个区域中的 servlet URL 你将在这个标签区域中得到 servlet 输出

if you want the servlet output in profile.jsp如果您想要 profile.jsp 中的 servlet 输出

instead of this而不是这个

<a href="ReportGeneration.jsp">View Report Generation</a>

use this用这个

<jsp:include page="/ReportProcess" /> 

as suggested by @Scary Wombat正如@Scary Wombat 所建议的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM