Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 28th, 2003, 09:29 AM
Lindagain Lindagain is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 4 Lindagain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
JSP passing id parameter within a link

I have a webpage that dynamically generates a list of courses from our database using a stored procedure to do all the sql statements. I am only a beginner so my supervisor sets up all the hard stuff and I just call stored procedures and pass them parameters or get parameters from them. I want each course to link to a detail page. My course detail page is going to be generated dynamically from 3 tables on the database but from a beginner's point I am forwarding to a static page for now. I am trying to pass the course ID when the user clicks the course link.

The code I'm using to generate the course list is:
<td>
<a href="<%= CONTROLLER %>?service=<%= SVCPREFIX %>olcourses.OLCourses&target=<%= WEB_NAME %>/olcourses/courseDetails.jsp&mode="clientcoursedetails"
&CourseID="<%=display_courses.get("CourseID")%>">
<%=display_courses.get("CourseTitle")%></a>
</td>

Display_courses.get prints the course title in my table. CONTROLLER, SVCPREFIX and WEB_NAME are constants in a jsp page I import. They define paths I use repeatedly. olcourses.OLCourses is my class file that calls the stored procedure I call in if statements that test the mode. So I can use one class file to get a list of courses, get course details, add, update or delete courses, etc. The mode is used to get the correct stored procedure.

The previous index page has a submit button calling a stored procedure to get 4 parameters from the database and put them in a hashmap. I use display_courses.get("CourseTitle") to get the name of the course and I figure I can use the same line to get CourseID and pass it to the detail page.

I get the static course details page to display but the url at the top says "http://localhost:8080/conestoga/servlet/Controller?service=edu.conestoga.web.olcourses.OLCourses&target=/web/olcourses/courseDetails.jsp&mode=". It looks to me like it is cutting off part of the url. And my course ID is after the mode so I am not getting the course ID to start generating the next page.

Am I doing somethign wrong that is cutting this off prematurely? Is there a way to use a session to pass the courseID? I am only used to passing parameters using form and hidden input tags so I'm not sure how to get a link to pass the courseID or to use a session to pass it.

Any advice is greatly appreciated!
Linda

Reply With Quote
  #2  
Old May 28th, 2003, 10:31 AM
Lindagain Lindagain is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 4 Lindagain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ok, I figured it out. I kept getting my link cut off at &mode=. If I tried to put the CourseID in front I'd get cut off at &CourseID=. So I put both of those in variables.

<% String CourseID = (String)display_courses.get("CourseID");
String passMode = "clientcoursedetails"; %>

Then I just used the variables.
&mode=<%=passMode%>
&CourseID=<%=CourseID%>

and it finally worked

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > JSP passing id parameter within a link


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway