• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1193
  • Last Modified:

JSP:Forward problem....Urgent

Hi
I have two applications employerWeb and shoppingWeb running on WebSphere.
I am unable to forward the page from employerWeb to shoppingWeb?

I am forwarding the page from http://localhost:9080/employerWeb/dept/redirect.jsp to
http://localhost:9080/shoppingWeb/signOn.do

here is my code

String strurl = "../shoppingWeb/signOn.do";
String strurl = "http://localhost:9080/shoppingWeb/signOn.do";

<jsp:forward page="<%= strurl %>" />

its giving error

org.apache.struts.action.RequestProcessor processMapping Invalid path /dept/../shoppingWeb/signOn.do


please help

Thank you
0
mmsreddy
Asked:
mmsreddy
2 Solutions
 
suprapto45Commented:
Try

String strurl = "shoppingWeb/signOn.do";

<jsp:forward page="<%= strurl %>" />

David
0
 
rrzCommented:
>  I have two applications employerWeb and shoppingWeb running on WebSphere.  
I don't use  WebSphere  but I can tell you how we do it on Tomcat.  
To configure this in Tomcat 5.5 ,  we define a <context> element in a searate xml file for the employerWeb web app . I don't know where this element is defined in WebSphere. This context element must  include the crossContext attribute.  In Tomcat 5.5 it likes like
<Context docBase="${catalina.home}/webapps/employerWeb"
              crossContext="true">
</Context>  
Once we do that, the following scriptlet will forward to the shoppingWeb web app.  
<%
    ServletContext employerWebContext = application.getContext("/shoppingWeb");
    RequestDispatcher rd = employerWebContext.getRequestDispatcher("/signOn.do");
    rd.forward(request,response);
%>
Maybe someone that uses WebSphere will help.   rrz
0
 
rrzCommented:
sorry that should have been this
<%
    ServletContext shoppingWebContext = application.getContext("/shoppingWeb");
    RequestDispatcher rd = shoppingWebContext.getRequestDispatcher("/signOn.do");
    rd.forward(request,response);
%>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
bloodredsunCommented:
You shouldn't use a RequestDispatcher externally. Forwarding a request means that the associated values such as session id is passed along also and this id has no meaning/value in the other application.

You should use response.sendRedirect or a tag that uses this such as <c:redirect>. Another option would be to read the other webapp from the first using an HttpUrlConnection.
0
 
mmsreddyAuthor Commented:
Hi
I want to pass two values to shoppingWeb from employerWeb without using query string.
How to send?. I think this may solve my problem

Thank you
0
 
rrzCommented:
bloodredsun,
>You shouldn't use a RequestDispatcher externally.    
I don't understand your comment. Please elaborate.
from
http://java.sun.com/j2ee/1.4/docs/api/index.html 
we have the desciption of a  RequestDispatcher given as
"Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server."
and from
http://java.sun.com/j2ee/1.4/docs/api/index.html 
we have  in the the description of ServletContext.getRequestDispatcher  
"Use getContext to obtain a RequestDispatcher for resources in foreign contexts."  
I just assumed that the dispatcher took care of the details.  Am I wrong ?
>Forwarding a request means that the associated values such as session id is passed along also and this id has no meaning/value in the other application.
I don't use WebSphere but Tomcat does retain the same session id but drops the request and session attributes.

>I want to pass two values to shoppingWeb from employerWeb without using query string.
Are these two applications in the same container(WebSphere) ?
>without using query string.  
What are your concerns ? Do you want to keep them private ?  If you use a forward then it is not a problem because they will stay within server. But redirection will expose them. Maybe bloodredsun will have another idea.   rrz
0
 
mmsreddyAuthor Commented:
Yes, the 2 WebSphere applications are in same WebSphere application server.

I want to keep the two  variable as private.

I tried with jsp:forward and dispatcher.forward are not working.

--msr
0
 
rrzCommented:
Does  WebSphere have an equivalent to Tomcat's  "crossContext"   attribute  ?
0
 
mmsreddyAuthor Commented:
NO, WEBSPHERE 5 have Shared Session context but WEBSPHERE 6 doesn't. We are using Websphere6.
0
 
rrzCommented:
If you can't get forward to work, then maybe you will have to use a redirect as suggested by bloodredsun. Maybe he will have an idea how to encrypt  your parameters.      rrz
0
 
mmsreddyAuthor Commented:
response.sendredirect also doen't worked.

I have set the req.setAttribute("ss",ss) calling response.sendredirect(). The parameters are not passing to other page.

0
 
rrzCommented:
>I have set the req.setAttribute("ss",ss) calling response.sendredirect().  
That won't work because the browser will make a new request when redirected.   What about encrypting your parameters ?  I don't know how though. I guess we could come up with something. Anybody ?
How much sercurity do you need. Will a simple algorithm  suffice ?  
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now