• 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

form handling in jsp

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dear all
the following is a brief description of my exercise.(am a beginner to jsp and trying hard to master it)
there are a list of 20 items with checkboxes.items are stored in the database.when i click on the link called show list it will show all 20 items.i may check 5,10 or 15 items and submit it.the jsp will process that list and show only the selected ones. the number of items selected may vary from session to sesion
any one who could be able to throw some light into it
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
premraj
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

As far as your question goes, have you tried anything for it yet. Let us know what you ahve so far and what you are stuck on then we can help you out. If your stuck at the very beginning then try to figure out what you need to do.
From your description it sounds like you need to give the user a page that contains all of the items from the database listed as checkboxes. so you need to:
Create a JSP or servlet (this sounds more like a job for a servlet - unless it's homeowrk and you have to use a JSP). If it has to be a JSP can you use a bean?
After you have the inital page created then add code to access the database and get the list of items.
Loop through the list of items and add each one to the page as a checkbox.
After the user selects howevermany they want to then have the page submit to another servlet/JSP that checks all of the items fromt he ifrst and only displays the checked ones.
That's a rough outline of what you need to ge started, if you have any code already let us know or if it is a specific part that you need help with.
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you followed this link? It's got some check boxes and it's pretty much the same of what you're explaining..
it might help.
cheers
 
prem raja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi dave
i started doing exactly what you have told.the following is my code for displaying all the listings from the database.now i want to check only a selected few and show only those things.
thanx
prem

<html>
<head>
<title>
Show Responsibility list
</title>
</head>
<%@ page language="java" import="java.sql.*" %>
<body>
<h1>Responsibility List</h1>
<table border="1" width="400">
<form action="showSelectedList.jsp" method=post>
<tr>
<td><b></b></td>
<td><b>Responsibility</b></td>
<td><b>Role Name</b></td>
</tr>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc racle:thin:@172.16.40.53:1521:cms","system","manager");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM SCOTT.CMS_responsibilities");

if (rs != null)
{
while (rs.next()){
String respoid=rs.getString("respo_id");
String responame=rs.getString("respo_name");
String rolename=rs.getString("role_name");

%>
<tr>
<td><input type=checkbox name=respoid value=<%=respoid %></td>
<td><%=responame %></td>
<td><%=rolename %></td>
</tr>
<%
}
}
stmt.close();
con.close();
%>
<tr colspan=5>
<td><input type=submit value="Show Selected Items"></td>
</tr>
</form>
</table>
</body>
</html>
 
no wonder he is so sad, he hasn't seen this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic