Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:forward doubt??

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When we use a jsp:forward, everything else gets ignored but the parameters survive...what logic is this?? The below example,

forward.jsp,

<jsp:forward page="animalHouse.jsp">
<jsp aram name="animaltypes" value="cat" />
</jsp:forward>

animal.jsp,

<% String[] a = request.getParameterValues("animalTypes");
for (int i = 0; i < a.length; i++) {
out.write(a[i] + ";");
}
%>
The output
cat;dog;

How??
 
nitin pai
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Each JSP has its own _jspService() method.
2. The signature of the method is _jspService(request, response)
3. A jsp:forward does nothing but calls the _jspService method of the other JSP
4. During the call the request, response objects are passed to the other JSP

Thus you are able to access the request parameters in the other JSP and nothing else from the first JSP. (if you havent stored something in application or the session objects)
 
Sergio Tridente
Ranch Hand
Posts: 329
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by nitin pai:
Thus you are able to access the request parameters in the other JSP and nothing else from the first JSP. (if you havent stored something in application or the session objects)


... or in the request object.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic