• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between servlets parameters and arguments

 
Micale Raj
Ranch Hand
Posts: 30
Hibernate IntelliJ IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are differences between servlets parameters and arguments and how to access parameters and attributes ?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I understand an attribute can be a java object. A parameter is something passed across in the HTTP POST or GET


or
take a look at http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it would also be useful reading up about HTTP POST and HTTP GET if you dont know.
 
Nandhakumar Soundarrajan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Mayura,

Hope you are trying to find the difference b/w request parameter and attributes.

Request Paramter:
Request Parameter are name value pairs and both the name and the value are strings.

Consider that you have a form with a text box say , so when this form is submitted to a servlet or another JSP. You can get the value entered by the user in the textbox (firstName), through which returns the value entered in the textbox.


Request Attributes:
Request Attributes are objects, and can be placed in the request, session, or context. As they are objects and not just String, they are much more flexible to use. You can set attributes programatically and retrieve them later.

Consider in a JSP page you have a connection object and you are setting it to the request attribute through the code
you can retrieve the Connection object in servlet by using the following code.


Note: You need to cast the object which you retrieve from request attribute.

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic