Forum Moderators: phranque

Message Too Old, No Replies

Redirect causes URL query string to be dropped

Redirect causes URL query string to be dropped

         

monocongo

9:01 pm on Oct 14, 2004 (gmt 0)

10+ Year Member



In Apache I'm redirecting a URL to a servlet which is being served by JBoss/Tomcat (JBoss 3.2.5) on the same machine listening on port 18080. This is being done by using a Redirect directive in the httpd.conf file. For example:

Redirect /PutMsg [myserver.mycompany.local:18080...]

(I expect that there's a better way of doing this, and perhaps this is the cause of my trouble.)

The web client that I have to support is written with a combination of HTML and JavaScript. The servlet can be called either as a form action from the HTML (<form action="/PutMsg">) or as a location of a JavaScript control (I think that's right -- I don't know JavaScript).

When the call comes from the JavaScript control the URL is redirected with the query string intact, and my servlet is happy. But when it is called as the action of the HTML form submission then the URL is redirected OK but the query string is lost, and hence my servlet has no parameters to work with.

Can anyone suggest why this is happening? Bear in mind that I'm a Java/J2EE develoer with only a limited knowledge of how Apache works, so I may be missing something which would be very obvious to someone with more Apache experience.

Thanks in advance for any feedback.

--James

jdMorgan

10:24 pm on Oct 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



James,

Welcome to WebmasterWorld!

It's likely the reason this does not work is that you are trying to do something that is not supported by HTTP [w3.org].

If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.

Simple answer: Don't try to redirect POSTs - It is a security violation.

Jim

monocongo

11:30 pm on Oct 14, 2004 (gmt 0)

10+ Year Member



Thanks so much for this information.

Is there another way of rerouting these requests? I want to have the URLs in question bypass Apache and instead go to the servlets which are being served by JBoss/Tomcat on another port. Is there a way in UNIX to do something like "map /PutMsg to /PutMsg at port X, and don't let Apache handle it first"?

--James

jdMorgan

11:33 pm on Oct 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I dunno, maybe the ProxyPass directive in Apache mod_proxy will be helpful... I haven't used Tomcat.

Jim