• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Passing a Querystring from one page to the next

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to pass a value with a querystring to another page and run a query based on it.

Example:
Page 1
I would click on the following link.
<a href="deleteCD.jsp?cd_id=<%= search.getCDID() %>">Delete</a>

Page 2
I have this for my SQL in my DeleteCDBean.java file:
String cdid = "";
ResultSet results = statement.executeQuery(
"SELECT * FROM CD, ARTIST, GENRE, ADVISORY, LOCATION WHERE CD.ARTIST_ID = ARTIST.ARTIST_ID AND CD.GENRE_ID = GENRE.GENRE_ID AND CD.ADVISORY_ID = ADVISORY.ADVISORY_ID AND CD.LOCATION_ID = LOCATION.LOCATION_ID AND CD_ID = " + cdid + " ");

I also have this to get the value from the URL:
<%
String cdid = request.getParameter("cd_id");
%>

For some reason I can't get the cd_id that is passed from the 1st page to insert itself into the SQL.

Any suggestions?
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly, just basic debugging techniques. Did you check to see what the state of the parameter was after you passed it? I'm betting it was a mess because you didn't URL encode it.

Secondly, why are you passing it at all? Why not pass a simple key that you can match up to the complex query?

Thirdly: the obligatory admonition against structuring your app to do SQL in the JSPs.
[ June 05, 2004: Message edited by: Bear Bibeault ]
 
Matt Hoffman
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks.. Since I am new a this, I am not sure what you mean about passing a key. Any examples are resources that I can look at?
 
Matt Hoffman
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did do some debugging and I am able to pass the ID using the dynamic link to the following page. I stored the ID in a hidden field on the following page and it is displaying the correct ID.
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic