File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Query String Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Query String Problem" Watch "Query String Problem" New topic
Author

Query String Problem

vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
I am working on an application using Struts. I have problem in getting the query string parameter in the jsps.

I have a tile based approach and in one of the tiles there is one jsp page which I am using for search. After the search is done, the results are displayed on the same page with an added column (select box) for actions(like duplicate, delete and so on). Also the <html:form action="/aa.do"> is only till the search button and the results are not inside the form.

So, now if the user selects any action(delete, duplicate ...), I need to goto another page and I need to get the selected action value. If the user has selected delete, I need to get the value "Delete" in the next page.

Since the select box is not in the form, I used onclick function and called a javascript. In the javascript I am getting the selected value. Then I am appending the value as a query string, but I am not getting the value in next page.

The select box is
Javascript is



Here I am using request.getParameter("test"), also tried session.getAttribute("test") (since the form scope is session), but both of them are null.

What am I missing here? I am sure it must be a small thing, but I am not able to figure it out.

Thanks for any help.
Prasanth Pillai
Ranch Hand

Joined: Oct 16, 2006
Posts: 52
the issue is not clear. where exactly are you setting the session/request parameter? I guess you are not doing that part.
David Dhune
Greenhorn

Joined: Sep 28, 2006
Posts: 14
try changing the name from "action" to something else at the following place

------------------------
<select name="action"

---------------------------
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Thanks for the replies. I tried changing the name to others. Also I was just testing the query string that I am setting in the javascript.



I am using request.getParameter("test") in the action class. I am not getting the value asdf, its just null.

Am I missing s omething obvious?

Thanks
David Dhune
Greenhorn

Joined: Sep 28, 2006
Posts: 14
exactly the same issue I faced before, but for me I did two things and it worked for me.

1. I changed the name of the of the selected box from "action" to someother name and also in the ActionForm (which you already did).

2. in javascript, my forms[0] was pointing to the form which is in header not to the form in content page, so whenever I was passing the value in query string, it was getting null. so I changed it to forms[1]. I was submitting the action (.do) with query string from the javascript. Just see is this correct in your javascript.
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
Thanks for the replies.

I now use 2 forms in that page and I am setting a hidden variable and getting the value.

Thanks for the help again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Query String Problem