Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"%=request.getParameter('redirectto')%" is this the correct syntex??

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume that in your JSP page, you need to forward the request to another page. The url to this page is given by a request parameter named 'redirectto'.

Which of the following code snippets do the above task?

1. <jsp:forward page="request.getParameter('redirectto')" />
2. <% request.getRequestDispatcher( request.getParameter("redirectto") ).forward(request, response); %>
3. <jsp:forward page="%=request.getParameter('redirectto')%" />
4. <jsp:forward page="<%=request.getParameter('redirectto')%>" />

5. <jsp:forward page="%request.getParameter('redirectto')%" />

the correct answer are 2,3,4.. I wonder if we use this syntex without any error "%=request.getParameter('redirectto')%

please clear my doubt..


thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think 3 would be correct, but for JSP documents only. Check "JSP.6.2.2 Overview of Syntax of JSP Documents" in the specification :
Scriptlet expressions used to specify request-time attribute values use a slightly different syntax in JSP documents than in non JSP documents; rather than using <%= expr %>, they use %= expr %. The white space around expr is not
needed, and note the missing < and >. The expr, after any applicable quoting as in any other XML document, is an expression to be evaluated as in Section JSP.1.14.1.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do we need to study this for the exam.. because HFSJ dosen't cover that much extra details??



 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Know the basics about JSP documents. I can't tell if this kind of detail is at the exam though. I think that what is in HFSJ 2nd Edition should be enough. If it's not in, then there are good chances that it's off topic.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes may be you are right !! because HFSJ dosen't cover these stuff in details.. In this book all the XML document related stuff covers only with a single page.. That's all


Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic