Ad

Redirect The Servlet Request To Another Servlet

- 1 answer

In our app for all the notification we trigger through mail.

All the templates have non sso link >/Userlogin?param1=param2value&param2=param2value">Link to access app

I need to modify this link in all templates to

>/Userloginsso?param1=param2value&param2=param2value">Link to access app

Since there are many templates and takes lot of manual effort, is there any way we can redirect the request of Userlogin to Userloginsso. Any configuration that we can do in web.xml ?

Ad

Answer

Considering you have a mapping for Userlogin in web.xml as below:

<web-app>
    <servlet>
         <servlet-name>Userlogin</servlet-name>
         <servlet-path>com.something.Userlogin</servlet-path>
    </servlet>
    <servlet-mapping>
         <servlet-name>Userlogin</servlet-name>
         <url-pattern>/Userlogin</url-pattern>
    </servlet-mapping>
</web-app>

Modify existing mapping to :

<web-app>
    <servlet>
         <servlet-name>Userloginsso</servlet-name>
         <servlet-path>com.something.Userloginsso</servlet-path>
    </servlet>
    <servlet-mapping>
         <servlet-name>Userloginsso</servlet-name>
         <url-pattern>/Userlogin</url-pattern>
    </servlet-mapping>
</web-app>

Now all calls to Userlogin will be redirected to Userloginsso servlet.

Ad
source: stackoverflow.com
Ad