Difference between Request Parameters and Scoped variables in Servlet and JSP.
Request parameters come from the browser (the HTML).
They can be sent to the server as QueryString parameters:
Code:
"http://myApp?first_name=Geetu"
or as Form Parameters:
Code:
form method="post" action="myApp"
input type="text" name="first_name" value="Geetu" /
input type="submit" value="Enter" /
/form
You would retrieve these in your servlet with: request.getParameter("first_name")
In a JSP, with EL you retrieve it with the param keyword:
${param.first_name}
They can not be objects because browsers can't send objects. They are always Strings or arrays of Strings.
Scoped variables, on the other hand are objects which are bound to page, request, session, or application scope. These variables can be accessed directly from EL
Objects are bound into the scopes using the setAttribute method in one of those scopes in Servlet, or using c:settag in JSTL, or even using jsp:setProperty tag in JSP Standard Action Tag which will create and bind a variable into a scope if it does not already exist.
They can be sent to the server as QueryString parameters:
Code:
"http://myApp?first_name=Geetu"
or as Form Parameters:
Code:
form method="post" action="myApp"
input type="text" name="first_name" value="Geetu" /
input type="submit" value="Enter" /
/form
You would retrieve these in your servlet with: request.getParameter("first_name")
In a JSP, with EL you retrieve it with the param keyword:
${param.first_name}
They can not be objects because browsers can't send objects. They are always Strings or arrays of Strings.
Scoped variables, on the other hand are objects which are bound to page, request, session, or application scope. These variables can be accessed directly from EL
Objects are bound into the scopes using the setAttribute method in one of those scopes in Servlet, or using c:set
0 Comments:
Post a Comment
<< Home