wood burning stoves 2.0*
The moose likes Servlets and the fly likes Request object in MVC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request object in MVC" Watch "Request object in MVC" New topic
Author

Request object in MVC

Ashraf Fouad
Ranch Hand

Joined: Oct 07, 2001
Posts: 80
Dear all,
I have some inquiry about the request object, I'm using MVC implementation recommended by IBM, where JSP submits to a controller servlet which redirect the request & response over appropriate class handlers, My question is:
- The nature of the request object, as I don't figure its behaviour, let me be more clear about what I mean:
JSP submits to a controller servlet which figure which handler the JSP requires & passes the request & response to this handler which take what it needs of parameter passed to it using getParameter, or getParameterValues methods and do some logic and passes the result to a JSP after adding the result in the SAME request object using setAttribute method, and then uses getServletContext().getRequestDispatcher( p_szPage ).forward( p_Request, p_Response ); to submit to a second JSP.
I want to know how the request object differentiate between parameters passed to it from the first JSP & the attributes he is sending to the second JSP.


Ashraf Fouad
SCJP 1.2, SCBCD 5
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Ashraf
The biggest difference is that the data sent in the request by the original form/page is stared as parameters while the data added by the servelt woould be attributes. As you said, you get the parameter values out with getParameter or getParameterValues and with attributes you'd use getAttribute or getAttributeNames. Once the parameters are set you cant change them except by invalidating the entire request object itself.
There are other differences but that is the most obvious and probably the most helpfuil for what you're trying to do.
hope that helps


Dave
Ashraf Fouad
Ranch Hand

Joined: Oct 07, 2001
Posts: 80
1- I want to know when the parameters & attributes are invalidated or removed in the MVC, and by whom?
2- I have an object that is maintained through several pages & I don't want to use the session because I can't determine when to remove it from session, I want to pass it in the request from the JSP to the Handler, how could this be done? can setAttriute be called in the JSP, I tried it but it returns null in the handler.
But it seems the only possible way to me.
Any help
Amir Kamran
Ranch Hand

Joined: Apr 21, 2002
Posts: 48
Hello!
U can setAttributes in jsp and can get it back in servlets.
U write u dont know when to remove the object from session. U r the programmer and if u dont know ... i think u not know what u want to do and how to impliment MVC.
If u give some code snipts of what u want to do than may be we can help in better way.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request object in MVC
 
Similar Threads
STRUTS: WHY???
MVC Architecture.
Best way to get object from ServletContext via a request
Redirecting to an outside URL from HandlerInterceptor
MVC Architecture