• 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

ServletRequest or HttpServletRequest ?

 
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For JSP scopes of request, what class of object is used to store to attributes?
ServletRequest or HttpServletRequest ?
My assumption is HttpServletRequest...am I right ?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are right.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nazmul
The implicit request object is a sub-type of the ServletRequest class. So, it could be HttpServletRequest. Or it could be some other class, it is protocol dependent.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is the ServletRequest class object which is used to store attributes in request scope.
I refer to the following context from SCWCD Kit Book, Section 12.3, pg218.


Data is shared between servlets using the three container objects, ServletContext, HttpSession and ServletRequest.
The JSP technology, since it is based on servlet technology, also uses the three scopes, which are referred to in JSP pages as application, session and request scopes.


Any verification on this matter is welcome.
Thambi
 
Ranch Hand
Posts: 498
Eclipse IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ServletRequest is abstract, so we can�t create object of this type.
Also, in the JSP Syntax is declared that the object request is: "Subclass of javax.servlet.ServletRequest".
 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So...whats the conclusion ? ServletRequest ?
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nazmul Huda Sarkar:
So...whats the conclusion ? ServletRequest ?


Yes, it's javax.servlet.ServletRequest as Dave already mentioned. For more information, you can check the JSP 1.2 specs Table JSP.2-1 Implicit Objects Available in JSP Pages.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As per JSP 1.1 Specs
3.2.2
The request and response interfaces together describe a protocol-dependent contract between
the JSP container and the class that implements the JSP page. The contract for HTTP is
defined by the javax.servlet.http.HttpServletRequest and
javax.servlet.http.HttpServletResponse interfaces.
So It should be of type HttpServletRequest.
 
Nazmul Huda Sarkar
Ranch Hand
Posts: 317
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yessssss Ashish Kurmi....I'm 100% with u.....If anyone see the converted servlet Java file in work folder, u will find that the signature of service method is :
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException

But, ofcourse HttpServletRequest is a subclass of ServletRequest
[ September 25, 2002: Message edited by: Nazmul Huda Sarkar ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's HttpServletRequest!
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I think that it is HttpServletRequest coz all the HTTP protocol dependent functionality is handeled by it.And as such JSP pages (the request) comes from HTTProtocol ,right?
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Attributes are stored in object of class ServletRequest
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it is ServletRequest.
HttpServletRequest inherits the method set/getAttribute() from ServletRequest, which is why so many of my fellow coyboys are confused.
from J2EE 1.3 API
javax.servlet.ServletRequest
java.lang.Object getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.

Hope this resolves the issue.
Thomas
[ October 04, 2002: Message edited by: Thomas Hubschman ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic