You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mario Laureti <Ma...@rcmp-grc.gc.ca> on 2001/04/19 16:08:57 UTC

An HTTP POST goes in the Action.perform(..) method, what about the HTTP GET?

Hello,

  I have 2 questions:

  1) How can I catch when a HTTP GET is performed on an action?

  2) Also in the web.xml can we define a "sort of" welcome-action?

      <welcome-action-list>
         <welcome-action>login.do</welcome-action>
      </welcome-action-list>

      Instead of

     <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
     </welcome-file-list>

Many thanks in advance.

Mario Laureti



  


Re: An HTTP POST goes in the Action.perform(..) method, what about the HTTP GET?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 19 Apr 2001, Mario Laureti wrote:

> Hello,
> 
>   I have 2 questions:
> 
>   1) How can I catch when a HTTP GET is performed on an action?
> 

By default, the Struts controller servlet treats GET and POST requests
identically.  Inside your action, you can detect which mechanism was used
(if you care) by calling request.getMethod().

If you wanted to globally disable GET requests to actions, one way would
be to subclass the ActionServlet class and override the doGet() method to
return an error instead.

>   2) Also in the web.xml can we define a "sort of" welcome-action?
> 
>       <welcome-action-list>
>          <welcome-action>login.do</welcome-action>
>       </welcome-action-list>
> 
>       Instead of
> 
>      <welcome-file-list>
>         <welcome-file>login.jsp</welcome-file>
>      </welcome-file-list>
> 

The servlet 2.2 spec is silent on whether this should work or not, so you
cannot count on it.

> Many thanks in advance.
> 
> Mario Laureti
> 

Craig