1

I want to change My URL name in Java.

Example

Suppose my URL name is www.xyz.com/join.html

I want to change this URL in my address bar to www.xyz.com/register-user

Can anybody suggest any way to achieve this?

Thank You.

Sharvil
  • 247
  • 1
  • 6
  • 15
  • 3
    You could handle this mapping in your `web.xml` file, [see here](https://stackoverflow.com/questions/11071131/web-xml-url-mapping). – Tim Biegeleisen Aug 12 '17 at 06:27
  • @TimBiegeleisen But I want dynamically change my URL suppose my currently Url is http://www.example.com/product.jsp?productId=123 and I want to show as http://www.example.com/product-name If U know about SEO I want to apply SEO in this Link so any body can visit this and google will find immediately the page. – Sharvil Aug 13 '17 at 06:08
  • What all are you using? Just the servlets or any other framework? – Abdullah Khan Aug 13 '17 at 08:56
  • @AbdullahKhan JSP and Servlet Only – Sharvil Aug 13 '17 at 09:05

1 Answers1

3

You need to fix your mappings in web.xml

<servlet>
    <servlet-name>RegisterUserServlet</servlet-name>
    <servlet-class>com.blahBlah.RegisterUserServlet</servlet-class> //Your servlets path
</servlet>
<servlet-mapping>
    <servlet-name>RegisterUserServlet</servlet-name>
    <url-pattern>/register-user</url-pattern> //if the url exactly matches register-user RegisterUserServlet will be called.
</servlet-mapping>

Check out this question on SO and this blog for more on what web.xml is.

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78