sendRedirect URL is appending with root url in JBOSS 7.2

309 Views Asked by At

I am migrating my application from JBOSS 5.0 to JBOSS 7.2 version server.

I am running 2 web projects in the same IP.

I am trying to connect from the first project servlet to the second servlet which is running in the another web project using sendRedirect() method.

After passing url to the sendRedirect() method it is appending with first projectcontext url (https://11.11.111.111:9999/servicename1/).

response.sendRedirect("https:/11.11.111.111:9999/servicename2/TestController?id=12345&testid=999999&sessionId=wFqBO7yz0itp52sVylWRBRwxSy6ZnMc-VsmdfAZf&tName=test");

https://11.11.111.111:9999/servicename1/https:/11.11.111.111:9999/servicename2/TestController?id=12345&testid=999999&sessionId=wFqBO7yz0itp52sVylWRBRwxSy6ZnMc-VsmdfAZf&tName=test

I am not getting any exception in the logs.

web.xml(From webproject1)

<web-app>
<servlet>
  <servlet-name>TestController</servlet-name>
  <servlet-class>org.test.controller.TestController</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>TestController</servlet-name>
  <url-pattern>/TestController</url-pattern>
 </servlet-mapping>
 </web-app>

Can someone please help me to resolve this issue. Thanks in advance.

1

There are 1 best solutions below

1
S Manikandan On

To redirect the request across the project from the same servlet container get the ServletContext by project name and use the request Dispatcher eg:-

ServletContext context=getServletContext().getContext("/projectName");
RequestDispatcher rd=context.getRequestDispatcher("relativeUrl of the other project");
// rd.forward(req,resp) or rd.include(req,resp); depends on the use case