I am newbie to jsp, i would like to insert data in one table whose half of the columns refer to first jsp page and rest of the element to other jsp page. Basically both are jsp forms which are being used to insert the user details into the database. Another query i have is how to fetch a data from database and show it in the form of options. Please reply, i am stuck with this in project
Asked
Active
Viewed 1,507 times
0
-
add table script and the jsp to your question. – Abhishek Nayak Feb 20 '14 at 17:57
-
You could split it into two tables, as user2412816 suggests, or insert the required fields in one JSP, and update the non-required fields in other. – developerwjk Feb 20 '14 at 18:45
-
@Gaurav Gupta, Please clarify your specific problem or add additional details to highlight exactly what you need. – jmail Feb 21 '14 at 06:27
1 Answers
0
Gaurav Gupta, the two forms are on two different pages has an implication, it means if you save the forms on a single table you need to Normalize your table. Which means they will be on two different tables;about normalization(What is Normalisation (or Normalization)? don't save them on a single table ,save them on two different tables and create relationship between the tables.
For your second question: I am not sure about your table structure, but you can use my code here as a reference,if you are not sure about how to connect to database and fetch result.
public static ArrayList<Device> getMonitoredDevices(){
ArrayList<Device> devices=new ArrayList<Device>();
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con=DriverManager.getConnection("jdbc:derby://localhost:1527/NetMon;user=NetMon;password=hacknet");
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select * from serviceMonitor");
while(rs.next()){
devices.add(new Device(rs.getString("deviceName"),rs.getString("deviceCategory"),rs.getString("deviceIP"),rs.getString("service"),rs.getString("status")));
}
return devices;
}
catch(Exception ex){
System.out.println("Exception raised"+ex.getMessage());
return devices;
}
}
to add values from the fetched result to a form option:
out.write("<option>"+value1+"</option">);
out.write("<option>"+value2+"</option">);
out.write("<option>"+value3+"</option">);
...
I hope it will help you,if you want more,make your question detailed and post your code.