This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Value shows up in url

 
Nick Davenport
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Plaer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
John Plaer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic