This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes JSP and the fly likes difference between getParameter() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "difference between getParameter()" Watch "difference between getParameter()" New topic
Author

difference between getParameter()

naveen jayant
Greenhorn

Joined: Jun 11, 2007
Posts: 6
hi i could not understand the difference between the following statement
both produce same result

<%=request.getParameter("email")%>
<%out.print(request.getParameter("email"))
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The first (which is called a JSP expression) is shorthand for the second.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Fabian Gutierrez
Greenhorn

Joined: Aug 15, 2004
Posts: 22
Thats right,

this is an expresion
<%=request.getParameter("email")%>

this is a scriplet
<%out.print(request.getParameter("email"))

basically you can use both, however the idea of JSP 2.0 is that you avoid those and instead use EL, for example:

${param.email}

regards,


SCJP 1.4, SCWCD 1.4, SCBCD 5, SCJD 5
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Also, I think it's worth pointing out that, in JSP 2.0 neither should be used.
They are both part of the scriptlet syntax.

In JSP 2.0 MVC architecture, JSTL (JavaServer Pages" Standard Tag Library), and EL (Expression Language) have replaced the need for scriptlets altogether.
 
Consider Paul's rocket mass heater.
 
subject: difference between getParameter()