• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Expression Element in Whizlabs Question

 
Santiago Bravo
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic