• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Query String Problem

 
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the issue is not clear. where exactly are you setting the session/request parameter? I guess you are not doing that part.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try changing the name from "action" to something else at the following place

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

---------------------------
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic