sending data from servlet to jsf page
Hi I have a requirement like this
1)There is some url with a parameters like
http://localhost:8080/MyApp/navigate?op1=alarm&op2=john&op3=6447479
where "navigate" maps to a servlet .
When user gets the above URL on the Address bar
if(op1.equals("alarms"))
then some JSF page will be called
if(op1.equals("logs"))
then some other JSF page will be called
when URL appearce on the page the 2 things should happen
1)op1 value is used for forwarding(navigating) to jsp
2)op2 value should be sent to that jsp
If i use resp.sendredirect then the jsp page called with full URL and images are visible but data
will not be sent to that page.
If I use RequestDispatcher (forward) then particular jsp page invoked and also i am able to send data to that jsp page.
But since URL won't change ,tha page is invoked but without any images .
So Plz help me how to make images visible when forwarded to jsf page.
Regards Raghavendra Pattar
# 1
> If i use resp.sendredirect then the jsp page called with full URL and images
> are visible but data will not be sent to that page.
Using sendRedirect() is the right way. But what do you mean with "data will not be sent to that page" ? If you want to pass objects from request to request, then just reuse the query URI or put the values in the requestMap or maybe even the sessionMap.
If you want to use the RequestDispatcher anyway, then you need to review the image path location. Likely you're using relative paths without specifying the root/base path.
# 5
Hi Balu requirement is like this.
1)ABC swing application is there .
It has one menu .User clicks on the menu Item .
It will construct an url and call our web application's JSF pages
URL is like this:http://host:8190/ContextName/navigate?op1=alarm&op2=workingzone10&sessionid=6373737
"navigate " I am mapping to a servlet.
"op1" value is used to call particular jsf page
ex:op1=alarm then our servlet which is mapped to navigate will redirect to
http://host:8190/ContextName/jsp/Alarms.faces
So servlet context navigate is changed to /jsp/alarm.faces
In alarm.faeces i should be able to retrive the other parameter values ie
op2=workingzone10
sessionid=6373737
If I store in sessionMap I am not able to get those values using sendirect
So while calling jsf page itself i am appending the parameters to URL
so url will look like this
http://host:8190/ContextName/jsp/Alarms.faces?op2=workingzone10&sessionid=6373737
I do not wan't to append like this i should get them internally in the jsf page.
Hope now problem is clear for u.(I can't use requestdispatcher.farward bcz image not come until we get full url)
Thanks
Raghavendra.
# 7
Hi balu,
I am not storing in the session map this is the partof code that i am using in my servlet.
String contextpath = req.getContextPath();
if (paramValue.equals("alarm") {
URL = "p1=" + paramlist.get("op") + "&" + "p2="
+ paramlist.get("workingzone") + "&" + "p3="
+ paramlist.get("sessionid") ;
res.sendRedirect(contextpath
+"/jsp/DisplayAlarms.faces"+ "?" + URL);
So The servlet will redirect to the jsp page whenever there is match
and the same parameters will be appended in the URL
So in the jsf page i am retrieving using
String parm1=req.getParameter("p1");
String parm2=req.getParameter("p2");
Like this
Thank U
bye.