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

[1040 byte] By [A9-pattar@aricenta] at [2007-11-27 3:32:27]
# 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.

BalusCa at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thank you balu i got the solution .I am using sendredirect and appending the data as a part of URL.
A9-pattar@aricenta at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
>>put the values in the requestMap or maybe even the sessionMap.can we pass session attributes using sendRedirect() ?i think we can not.
veerjaa at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You don't actually pass session attributes, but you just stores them. As long as you're inside the same user session and inside the same servletcontext, you can access them anywhere. Even after a sendRedirect to the URL in the same servletcontext.

Likely you're just in confusion with request attributes.

BalusCa at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

A9-pattar@aricenta at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
> "navigate " I am mapping to a servlet.> ...> If I store in sessionMapHow exactly are you storing the params in the SessionMap of the FacesContext from inside a HttpServlet?
BalusCa at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 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.

A9-pattar@aricenta at 2007-7-12 8:35:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...