• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Request object in MVC

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ashraf Fouad
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic