• 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

How to identify the method as "GET" or "POST"

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

In Servlets, we know whether a GET request has been issued by the browser or a POST as we have different methods there, namely doGet() and doPost(). How do we do that in Struts?

Thanks.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should be:

 
Robin Sharma
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Joseph Erickson:
Should be:



Joseph, my question is that does Struts provide a way as part of the framework to handle these two methods differently. I mean, in servlets, if it's a get request, automatically, the doGet() method gets called. Is such a thing possible in Struts also? Or do I have to programmatically check using request.getMethod() to have a separate logic in place for the two cases?

Thanks.
 
Joseph Erickson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to check explicitly, from what I understand. One of Struts' features is that you don't have to worry if it was a GET or a POST. It rolls all of that into one execute method.

You can override doGet and doPost, but that will break the whole Struts framework stuff. Not recommended. I would just do an if on request.getMethod();
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic