• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Value shows up in url

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic