Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Expression Element in Whizlabs Question

 
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?

 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • 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...
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic