aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletRequest or HttpServletRequest ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletRequest or HttpServletRequest ?" Watch "ServletRequest or HttpServletRequest ?" New topic
Author

ServletRequest or HttpServletRequest ?

Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
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 ?


Nazmul<br />SCJP,SCWCD,IBM OOAD with UML
GuanXing Fung
Greenhorn

Joined: Sep 17, 2002
Posts: 5
I think you are right.


scjp2
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
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.


Dave
Thambi Rajah
Ranch Hand

Joined: Jul 19, 2002
Posts: 36
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
Marcelo Sousa Ancelmo
Ranch Hand

Joined: Jan 17, 2002
Posts: 497

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".


Marcelo Sousa Ancelmo - Brazil
Nazmul Huda Sarkar
Ranch Hand

Joined: Feb 01, 2002
Posts: 317
So...whats the conclusion ? ServletRequest ?
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
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.
Ajay Hatkar
Greenhorn

Joined: Mar 31, 2002
Posts: 14
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

Joined: Feb 01, 2002
Posts: 317
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 ]
Michael Huang
Greenhorn

Joined: Sep 06, 2002
Posts: 1
It's HttpServletRequest!
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException


--------------<br />Michael Huang<br />SCJP,SCWCD
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
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?
Raj Paul
Ranch Hand

Joined: Jul 09, 2002
Posts: 77
Attributes are stored in object of class ServletRequest
Thomas Hubschman
Ranch Hand

Joined: Sep 25, 2002
Posts: 88
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 ]

SCJP '02, SCWCD '02, SCJD '08, SCSNB '09, SCEA '10
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletRequest or HttpServletRequest ?
 
Similar Threads
Question from Jweb +
JSP's request scope and request implicit object
For JSP scopes of request and page, what type of object is used to store the attribut
ServletRequest / HttpServletRequest
Mismatch in Chapter 7