You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Uwe Kubosch <do...@crusaders.no> on 2004/03/21 18:07:42 UTC

method="post" but doGet() called

Hi all!

I have a form (included below) where I set method="post", but for for a
specific action URL, it  arrived in the doGet method instead of the doPost
method.

I have a seervlet-mapping that pics up _all_ resquests to the context:

<url-pattern>/</url-pattern>

The unexpected behaviour comes when there is nothing after the context in
the action URL:

http://localhost:8080/mycontext

This arrives in doGet.

Putting something after the context works:

http://localhost:8080/mycontext/stuff

This arrives in doPost.

Is this correct behaviour?  I am using Opera as browser.  Should this make a
difference?


<html>
<head>
<title>Access Denied</title>
</head>
<body>
<h1 align=center>Access denied!</h1>
<div align="center">



</div>
<!-- Begin BOX 'Login'-->
<table border="2" align="center" width="1"><tr><td align="left">
<div align="left">
<h3>Login</h3>
</div>

<div align="center" border="1" width="1">
<form name="loginForm" method="post" enctype="multipart/form-data"
action="http://localhost:8080/espresso">
<input type="hidden" name="formObjectID" value="-4">
<input type="hidden" name="tab"    value="General">
<input type="hidden" name="defcmd" value="Login">
<table cellspacing="0" cellpadding="0">
<tr><td class="EspressoLogin">Login</td><td><input class="EspressoLogin"
type="text" name="EspressoUID" value="root" size="10"></td>
<tr><td class="EspressoLogin">Password</td><td><input class="EspressoLogin"
type="password" name="EspressoPWD" value="" size="10"
nonChange='document.loginForm.submit()'></td>
<tr><td colspan="2" align="center" nowrap><input class="EspressoLogin"
type="submit" name="cmd" value="Login">
</td>
</tr></table></form><script type="text/JavaScript">if
(document.loginForm.EspressoUID.value.length == 0)
{document.loginForm.EspressoUID.focus();} else
{document.loginForm.EspressoPWD.focus();}</script>
</div></td></tr></table><!-- End BOX -->
</body>
</html>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


SV: method="post" but doGet() called

Posted by Uwe Kubosch <do...@crusaders.no>.
> When Tomcat sees a request for 'http://localhost:8080/mycontext' it sends
> back a response to redirect to
> 'http://localhost:8080/mycontext/'.  This is
> so that relative links to things like images and stylesheets work
> correctly.
> If the browser conformed to the HTTP/1.1 RFC, it would re-request the new
> URL with a POST, but I don't know of any browsers that do this.

Thank's a million.  So I shouldn't spend more time trying to fix it?  Rather
I should add the trailing "/" myself to avoid the redirect?


donV


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: method="post" but doGet() called -> external redirects

Posted by Liviu Ionescu <il...@livius.net>.
> When Tomcat sees a request for 
> 'http://localhost:8080/mycontext' it sends back a response to 
> redirect to 'http://localhost:8080/mycontext/'.  This is so 
> that relative links to things like images and stylesheets 
> work correctly. If the browser conformed to the HTTP/1.1 RFC, 
> it would re-request the new URL with a POST, but I don't know 
> of any browsers that do this.

would it be possible to add a configuration parameter to certain contexts so
that the external redirects are replaced by internal forwardings?

I have a m2m application where the clients are not browsers, but simple
dedicated devices that do not implement redirects, and their standard way of
accessing the server is .../mycontext?x=a, so without a trailing '/'.

Since I could not find a url rewrite mechanism, like in Apache, I had to use
a dirty trick, I renamed my context to mycontext-app and I wrote a servlet
in the root context to forward requests from "/mycontext" to
"/mycontext-app/" (beware that .forward() is usually called in the current
context, if another context is needed it should be retrieved first)

having the rewrite done directly by Tomcat (is the DefaultServlet handling
this?) would be a more appropriate solution, imho.

regards,

Liviu


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: method="post" but doGet() called

Posted by Bill Barker <wb...@wilshire.com>.
When Tomcat sees a request for 'http://localhost:8080/mycontext' it sends
back a response to redirect to 'http://localhost:8080/mycontext/'.  This is
so that relative links to things like images and stylesheets work correctly.
If the browser conformed to the HTTP/1.1 RFC, it would re-request the new
URL with a POST, but I don't know of any browsers that do this.

"Uwe Kubosch" <do...@crusaders.no> wrote in message
news:CHECLDNPGHELOIINBBLECEOKGJAA.donv@crusaders.no...
> Hi all!
>
> I have a form (included below) where I set method="post", but for for a
> specific action URL, it  arrived in the doGet method instead of the doPost
> method.
>
> I have a seervlet-mapping that pics up _all_ resquests to the context:
>
> <url-pattern>/</url-pattern>
>
> The unexpected behaviour comes when there is nothing after the context in
> the action URL:
>
> http://localhost:8080/mycontext
>
> This arrives in doGet.
>
> Putting something after the context works:
>
> http://localhost:8080/mycontext/stuff
>
> This arrives in doPost.
>
> Is this correct behaviour?  I am using Opera as browser.  Should this make
a
> difference?
>
>
> <html>
> <head>
> <title>Access Denied</title>
> </head>
> <body>
> <h1 align=center>Access denied!</h1>
> <div align="center">
>
>
>
> </div>
> <!-- Begin BOX 'Login'-->
> <table border="2" align="center" width="1"><tr><td align="left">
> <div align="left">
> <h3>Login</h3>
> </div>
>
> <div align="center" border="1" width="1">
> <form name="loginForm" method="post" enctype="multipart/form-data"
> action="http://localhost:8080/espresso">
> <input type="hidden" name="formObjectID" value="-4">
> <input type="hidden" name="tab"    value="General">
> <input type="hidden" name="defcmd" value="Login">
> <table cellspacing="0" cellpadding="0">
> <tr><td class="EspressoLogin">Login</td><td><input class="EspressoLogin"
> type="text" name="EspressoUID" value="root" size="10"></td>
> <tr><td class="EspressoLogin">Password</td><td><input
class="EspressoLogin"
> type="password" name="EspressoPWD" value="" size="10"
> nonChange='document.loginForm.submit()'></td>
> <tr><td colspan="2" align="center" nowrap><input class="EspressoLogin"
> type="submit" name="cmd" value="Login">
> </td>
> </tr></table></form><script type="text/JavaScript">if
> (document.loginForm.EspressoUID.value.length == 0)
> {document.loginForm.EspressoUID.focus();} else
> {document.loginForm.EspressoPWD.focus();}</script>
> </div></td></tr></table><!-- End BOX -->
> </body>
> </html>




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org