aspose file tools*
The moose likes JSP and the fly likes Value shows up in url Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Value shows up in url" Watch "Value shows up in url" New topic
Author

Value shows up in url

Nick Davenport
Greenhorn

Joined: Jul 27, 2007
Posts: 12
I have a JSP web page that is redirected from another non Java web site where I fetch the parameter from the non Java web site and put it in the JSP web page. It works great but the value shows up in my JSP url on Tomcat 6.0.18 located on a Windows server.
The problem is I dont want the parameter value showing up in the url.

The redirected parameter value shows in my JSP url like this: http://mydomain/mysite.jsp?myvalue=jones
I want to hide or not show the myvalue=jones part of the url so it shows up like this:
http://mydomain/mysite.jsp

Here is how I am fetching the parameter:

The redirect from a non java page goes to a servlet:



I capture the value in the mysite.jsp and it works great but unfortunately shows the value also in the url:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61239
    
  66

Not much you can do about it.

When the other site redirects to your site with that parameter on the URL, there's nothing that you can do to hide it after the fact.

If you don't want the parameter to show, the other site will need to POST rather than redirect to your site.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
John Plaer
Greenhorn

Joined: Apr 09, 2009
Posts: 10

There is a workaround if you are really desperate

1. Store the myvalue in session instead of request
2. Use response.sendRedirect instead of Dispatcher.forward
3. Retrive the value in jsp from session instead of request

This might not be a good practice but should resolve your issue.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
As already mentioned, if you are in control of the site that did the redirect, then it has to be handled there. before the redrect.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
John Plaer
Greenhorn

Joined: Apr 09, 2009
Posts: 10
The redirect from a non java page goes to a servlet:


I assumed that you are in control of the servlet before a further redirection to your jsp
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61239
    
  66

John Plaer wrote:
There is a workaround if you are really desperate

1. Store the myvalue in session instead of request
2. Use response.sendRedirect instead of Dispatcher.forward
3. Retrive the value in jsp from session instead of request

This might not be a good practice but should resolve your issue.

He's already stated that the source is a non-java page. How is it going to obtain access to the session? the dispatcher?


John Plaer
Greenhorn

Joined: Apr 09, 2009
Posts: 10
I have a JSP web page that is redirected from another non Java web site where I fetch the parameter from the non Java web site and put it in the JSP web page.


Here is how I am fetching the parameter:

The redirect from a non java page goes to a servlet:


From the above lines by Nick and by looking at the servlet code it is quite obvious that the external website is pointing towards a servlet in which Nick is getting the url parameter and setting it in request context and dispatching to the locally placed mysite.jsp



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61239
    
  66

Which has nothing to do with the fact that the external site is putting the request param on the URL.

There is nothing that can be done short of changing the external site to prevent that.
John Plaer
Greenhorn

Joined: Apr 09, 2009
Posts: 10

Bear,

I totally agree with you that if the external site is putting the parameter in the url and when we get the control its already there in the url and nothing can be done with that.

my point is that the external site here (in this specific scenario) is not directly redirecting to the jsp. The external non java site is pointing to the ProjectServlet, as in http://mydomain/ProjectServlet?myvalue=abc and then this ProjectServlet dispatches the request to the mysite.jsp.


Now the problem mentioned is not with the url http://mydomain/ProjectServlet?myvalue=jones

The problem is with the url http://mydomain/mysite.jsp?myvalue=jones

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Value shows up in url