Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

passing id from jsp to servlet through url  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i was send the id through url like this code.

<td> <%=rs3.getString("Project")%> </td> <td> <a href="TaskAssignment.jsp?id=<%=rs3.getString("id")%>"> <input type="button" name="edit" value="Edit"></a></td>

i have problem to getting this id in servlet.

Servlet:

String id=request.getParameter("id");

the variable id getting only null
 
Ranch Hand
Posts: 579
6
Java jQuery
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this:

<td>Project 1</td>
<td><a href ="TaskAssignmentServlet?id=5"> sometext
<input type="submit" name="edit" value="Edit">
</a></td>


I think here in jsp code, you forgot to add the hyperlink text.. either way. from the given jsp code, I am getting the value in the servlet. also, the hyperlink is refering to JSP not SERVLET. is that what you missed?



 
Dinesh Ravi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried but i did't get the id value. it's value is null.

i was created a jsp page like taskAssign.jsp

this page getting a value and send values to servlet page for insert values to database. tha taskAssign.jsp page to show what are the data's inserted the database. if i want to update this details click the edit button. it's appers taskAssign.jsp?id=2 like this values are showing. if i click update the servlet page getting id value is null.

taskassign.jsp

Employee Name: <select name="empname" required="">
<option selected value="">Select Employee</option>
<% while(rs.next()){ %>
<option value="<%=rs.getString("EmpId")%>" <% if(emp.equals(rs.getString("EmpId"))) {%> selected <% } %>><%=rs.getString("EmpName")%></option>
<% } %>
</select><br>
Project Name: <select name="project" required="">
<option selected value="">Select Project</option>
<% while(rs1.next()){ %>
<option value="<%=rs1.getString("ProjectName")%>" <% if(proj.equals(rs1.getString("ProjectName"))) {%> selected <% } %> > <%=rs1.getString("ProjectName")%></option>
<% } %>
</select><br>

llike this.

same page showing the inserted values:

<tr>
<td>Project</td> <td>Employee</td><td>Task</td><td>Due Date</td> <td>Edit</td>
</tr>

<% while(rs3.next()){%>
<tr>
<td> <%=rs3.getString("Project")%> </td> <td><%=rs3.getString("EmpId")%></td><td><%=rs3.getString("Task")%></td><td><%=rs3.getString("DueDate")%></td> <td> <a href="TaskAssignment.jsp?id=<%=rs3.getString("id")%>">Click<input type="button" name="edit" value="Edit"></a></td>
</tr>

this code no problem.

i need to get the id value in servlet.
 
Bartender
Posts: 1800
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first step, and this is very important, is stop writing scriptlet code. Learn how to create a properly structured web application.

Start by ready this and this.
 
Dinesh Ravi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your suggestion.

And i got the id value.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you show me how you did it?
 
I've never won anything before. Not even a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!