Page 1 of 1

About Question enthuware.jwpv6.2.818 :

Posted: Wed Oct 10, 2012 5:10 pm
by ETS User
There is a bug big like an home!
You couldn't write this: page="%=request.getParameter('redirectto')%"
Please fix it!
Thanks

Re: About Question enthuware.jwpv6.2.818 :

Posted: Wed Oct 10, 2012 5:54 pm
by admin
As the explanation says, it is valid if the page is written in XML syntax instead of JSP syntax.

HTH,
Paul.

Re: About Question enthuware.jwpv6.2.818 :

Posted: Wed Nov 28, 2012 6:27 am
by tori3852
But quotes are not valid:

Code: Select all

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

Code: Select all

<jsp:forward page="<%=request.getParameter('redirectto')%>" />
It will not compile.

Also,
it is valid if the page is written in XML syntax instead of JSP syntax.
It is mentioned in question, that this is JSP page, so not in XML syntax (JSP document is in XML syntax). But it's just a matter of terms.

Re: About Question enthuware.jwpv6.2.818 :

Posted: Fri Jan 25, 2013 7:20 am
by harsh.sahajwani
This question has incorrect answers.

Option 2 works but Options 3 and 4 do not work.

Explanation says Option 3 is currect, which is:
<jsp:forward page="%=request.getParameter('redirectto')%" />
However, the response that I get when I write the above line in a jsp and hit it using URL: http://localhost:7070/Servlets/abc.jsp? ... to=def.jsp

The browser shows:

HTTP Status 404 - /Servlets/%=request.getParameter('redirectto')%

--------------------------------------------------------------------------------

type Status report

message /Servlets/%=request.getParameter('redirectto')%

description The requested resource is not available.

================================================================
Explanation says Option 4 is currect, which is:
<jsp:forward page="<%=request.getParameter('redirectto')%>" />
However, this JSP does not compile. And the response that I get when I write the above line in a jsp and hit it using URL: http://localhost:7070/Servlets/abc.jsp? ... to=def.jsp

HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.abc_jsp

--------------------------------------------------------------------------------

type Exception report

message java.lang.ClassNotFoundException: org.apache.jsp.abc_jsp

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.abc_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:177)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)


root cause

java.lang.ClassNotFoundException: org.apache.jsp.abc_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:172)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

Re: About Question enthuware.jwpv6.2.818 :

Posted: Fri Jan 25, 2013 4:06 pm
by admin
The issue is that the quoting conventions as described JSP 2.2 Section 1.6 are not implemented consistently by the containers. Ideally, the following three are equivalent:
<jsp:forward page="<%=request.getParameter('redirect')%>" />
<jsp:forward page='<%=request.getParameter("redirect")%>' />
<jsp:forward page="<%=request.getParameter(\"redirect\")%>" />
In tomcat, at some point when the question was tested, all three worked. But now the first one doesn't work but second and third still do.
We have updated it to avoid this issue.

thank you for your feedback!

Re: About Question enthuware.jwpv6.2.818 :

Posted: Sat Jan 26, 2013 1:16 pm
by harsh.sahajwani
Options 3 and 5 mentioned in the question have missing starting "<" and closing ">" signs. These are written in the question as:

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

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

This creates a lot of confusion when the explanation shows these options as correct. Please, fix it!

Re: About Question enthuware.jwpv6.2.818 :

Posted: Sun Jan 27, 2013 8:50 am
by admin
harsh.sahajwani wrote:Options 3 and 5 mentioned in the question have missing starting "<" and closing ">" signs. These are written in the question as:

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

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

This creates a lot of confusion when the explanation shows these options as correct. Please, fix it!
It is meant to create confusion. Option 3 is correct because in XML syntax, < and > are not used.
The option has been updated to make it more clear.
HTH,
Paul.