aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Expression Element in Whizlabs Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Expression Element in Whizlabs Question" Watch "Expression Element in Whizlabs Question" New topic
Author

Expression Element in Whizlabs Question

Santiago Bravo
Ranch Hand

Joined: Jul 25, 2008
Posts: 226
Whizlabs - The JSP Technology Model Test Q3:

A JSP page is accessed using the URL http://www.xyz.com/test.jsp?empno=1

Which of the following ways are valid to print the value of empno into the generated html output? Select two choices.

1. <%=request.getParameter("empno")%>
2. <%=request.getParam("empno")%>
3. <%=request.getParameter("empno");%>
4. <jsp:expression>request.getParameter("empno")</jsp:expression>
5. <% out.println(request.getParameter("empno")) %>

Choice 4 is definitely correct. Choice 5 would have been correct if it had a semi-colon. 2 is wrong due to the method name and 3 is wrong due to the additional semi-colon.

However, for choice 1 to be correct should there not be a space after the opening of the expression element? For example it should be:

<%= request.getParameter("empno")%> instead of <%=request.getParameter("empno")%>

Or is this optional?


Santiago
My Path to SCJP Certification My Path to SCWCD Certification
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

Santiago Bravo wrote:However, for choice 1 to be correct should there not be a space after the opening of the expression element? Or is this optional?

The best way to confirm is to try it yourself. There should be no space between <% and =, space after <%= and before %> is not required...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Expression Element in Whizlabs Question