Jsp Forward
Advertisements
Jsp Forward
This action tag is used for forwarding a request from a jsp to another jsp or a servlet or a html.
When use JSP Forward tag
Generally, if a huge logic is required in a jsp then we divide that logic into multiple jsp pages and then we apply forwarding technique.
Note: If destination is a jsp or html then file name is required and if destination is a servlet then url pattern is requied.
Save and Compile jsp program
JSP program must be save with the .jsp extension. And for compile jsp code simply follow step of compilation servlet code.
Example
<jsp:forward page="/srv1"/> <jsp:forward page="home.jsp"/> <jsp:forward page="index.html"/>
When a request is forwarded then along-with the request, automatically request parameters send from browser or also forwarded. If you want to attach additional parameters then we use <jsp:param> tag inside <jsp:forward> tag.
Example
<jsp:forward page="home.jsp"> <jsp:param name="p1" value="10"/> <jsp:param name="p2" value="20"/> </jsp:forward>
Google Advertisment