Connecting Tech Pros Worldwide Forums | Help | Site Map

Having problem in passing the parameters....

Newbie
 
Join Date: Mar 2007
Posts: 27
#1: Jun 21 '07
hi to all,

I am having some problem in passing parameter.....

My code looks like:::

request.setAttribute("game",game);
response.sendRedirect("profile.do?operation=select &max_profiles="+totalprofiles+"&fsa="+fsa+"&score= "+score+"&gameid=" + gameid + "&locale="+locale);


I simply want to pass the value of game parameter which contains name of the game i.e. "chess" on next JSP page.I am able to retrive value of ,rest of the parameters on next page.I also tried to append the game parameter in response.sendRedirect as other parameters but exactly when it excutes that line it gives some error.

but if i pass it in this way as shown above it excutes properly but on the JSP page i m not able to get the value of game...but got rest all values.

when i do system.out.println("game" + game); then i am getting game value ,its length is also proper and very next line is the code shown above
dont find what's the catch??

Question 1:
Is it possible to use request.setAttribute() and response.sendRedirect() simultaneously??


is there any other way to do so???


thanx...
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Jun 21 '07

re: Having problem in passing the parameters....


Quote:

Originally Posted by softwaregeek

hi to all,

I am having some problem in passing parameter.....

My code looks like:::

request.setAttribute("game",game);
response.sendRedirect("profile.do?operation=select &max_profiles="+totalprofiles+"&fsa="+fsa+"&score= "+score+"&gameid=" + gameid + "&locale="+locale);


I simply want to pass the value of game parameter which contains name of the game i.e. "chess" on next JSP page.I am able to retrive value of ,rest of the parameters on next page.I also tried to append the game parameter in response.sendRedirect as other parameters but exactly when it excutes that line it gives some error.

but if i pass it in this way as shown above it excutes properly but on the JSP page i m not able to get the value of game...but got rest all values.

when i do system.out.println("game" + game); then i am getting game value ,its length is also proper and very next line is the code shown above
dont find what's the catch??

Question 1:
Is it possible to use request.setAttribute() and response.sendRedirect() simultaneously??


is there any other way to do so???


thanx...

The simplest way to submit data from a JSP is through a form. Use a simple HTML form and pass the name of the game as a hidden input then you can use request.getParameter in the next JSP.
Newbie
 
Join Date: Mar 2007
Posts: 27
#3: Jun 21 '07

re: Having problem in passing the parameters....


Quote:

Originally Posted by r035198x

The simplest way to submit data from a JSP is through a form. Use a simple HTML form and pass the name of the game as a hidden input then you can use request.getParameter in the next JSP.


sorry for lack of information...

We are using spring framework. The code snippet which i mentioned is written in controller class that is java (.java) file..and that controller call the JSP page...we are not able to pass the game value to JSP page from controller using the code shown above.

Is there any problem in above code??

Thanx...
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Jun 21 '07

re: Having problem in passing the parameters....


Quote:

Originally Posted by softwaregeek

sorry for lack of information...

We are using spring framework. The code snippet which i mentioned is written in controller class that is java (.java) file..and that controller call the JSP page...we are not able to pass the game value to JSP page from controller using the code shown above.

Is there any problem in above code??

Thanx...

Is your controller a servlet?
Try
Expand|Select|Wrap|Line Numbers
  1. request.getRequestDispather("/jspPath.jsp").include(request, response);
Newbie
 
Join Date: Mar 2007
Posts: 27
#5: Jun 21 '07

re: Having problem in passing the parameters....


Quote:

Originally Posted by r035198x

Is your controller a servlet?
Try

Expand|Select|Wrap|Line Numbers
  1. request.getRequestDispather("/jspPath.jsp").include(request, response);


Thanx....

it worked but with little modification . I use forward in placeof include..
Did you find out why it didnt work with response.sendRedirect()?
Any specific reason why when i add game parameter then only it fails?? or when i pass it through request.setAttribute() then i cant retrieve it on JSP.

Cant we use both simultaneously??
Reply