1

I want to hide the url when redirected to page on other server. For Eg : This is the index.jsp Page

<body>
<form id="inset_form" >
<input type="submit" value="GO" onclick="func();">
</form>
</body>

When someone clicks on submit it will go to servlet.

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        System.out.println("Post");
        response.sendRedirect("https://stackoverflow.com/questions/14018215/what-is-url-pattern-in-web-xml-and-how-to-configure-servlet");
    }

Now it will redirect to the page on another server

https://stackoverflow.com/questions/14018215/what-is-url-pattern-in-web-xml-and-how-to-configure-servlet

Now I want the url like this : https://stackoverflow.com/questions/anotherPage

instead of

https://stackoverflow.com/questions/14018215/what-is-url-pattern-in-web-xml-and-how-to-configure-servlet

but it should redirect to same page only with some information hidden.

If it is possible then please help.

Thanks in advance.

Community
  • 1
  • 1
Vivek
  • 77
  • 3
  • 11
  • try to find something about mod_rewrite. not sure how is it done by jsp, but you can change the URL almost anyway – Eduard Void Jun 21 '16 at 16:53

2 Answers2

1

You'll want to use URL Rewrites: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Kodie Grantham
  • 1,963
  • 2
  • 17
  • 27
1

Unless you program your server to consider

page.com/way-to-long

To be the same as

page.com/better

Then I'm not sure this is possible. It can't be done in pure JavaScript because editing the URL could lead to phishing scams (I could change my scam site's URL to facebook.com after the loading is done). Other people linked how to do it with Mod_rewrite on an Apache surver.

master565
  • 805
  • 1
  • 11
  • 27