• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Expression Element in Whizlabs Question

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic