aspose file tools*
The moose likes JSP and the fly likes form handling in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "form handling in jsp" Watch "form handling in jsp" New topic
Author

form handling in jsp

prem raja
Greenhorn

Joined: Jun 04, 2002
Posts: 17
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
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
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.


Dave
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
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


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
prem raja
Greenhorn

Joined: Jun 04, 2002
Posts: 17
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: form handling in jsp