wood burning stoves 2.0*
The moose likes Struts and the fly likes How to identify the method as Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to identify the method as "GET" or "POST"" Watch "How to identify the method as "GET" or "POST"" New topic
Author

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

Robin Sharma
Ranch Hand

Joined: Aug 24, 2005
Posts: 76
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.


DW
There is always a bug :-)
Joseph Erickson
Greenhorn

Joined: May 05, 2006
Posts: 10
Should be:

Robin Sharma
Ranch Hand

Joined: Aug 24, 2005
Posts: 76
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

Joined: May 05, 2006
Posts: 10
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();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to identify the method as "GET" or "POST"