• 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

how to populate optional values got from database in the SELECT BOX

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="beans.register2" %>
<jsp:useBean id="registerbn" scope= "session" class="beans.register2" />
<% String base = (String) session.getAttribute("base");
registerbn.setDburl((String)session.getAttribute("dbUrl"));
registerbn.setDbuser((String)session.getAttribute("dbUserName"));
registerbn.setDbpasswd((String)session.getAttribute("dbPassword"));
System.out.println("Inside jsp - setMembers of promotion successful");
registerbn.setMembers();
System.out.println("after setting");
%>
<%
String action=request.getParameter("action");
%>
<HTML>
<HEAD>
<TITLE> TIFR INTRANET </TITLE>
</HEAD>
<HEAD>
<script language="_JavaScript1.2">
function isIdcode()
{
/ validating
}
function isUser()
{
/ validating
}
function isEmail()
{
/ validating
}
function isPassword()
{
/ validating
}
function isDob()
{
/ validating
}
</javascript> -----java script ends here----------------
<TD align="top" valign="top"><jsp:include page="menu.jsp" flush="true"/>
</td>
<td>
<table cellpadding="2" cellspacing="3" width="40%">
<form method="post" action="./beans.register2">
----------------
Fisrt question: we have creaated "register2.java "as beans class for setting the values in to the data base.
is it correct ?
-----------------
<td width="40" align="center"
<font face="arial" size="5" align="right">
<b>
Registration <hr> </hr>
</b>
</font>
<br>
</td>
<tr valign="center" width="80%">
<td width="40%">
<b><font face="Arial" size="2">IdCode </b> </font>
</td>
<td width="40%">
<b><font face="Arial" size="2">
<input type="text" name="idcode" size="6" style="border-style:solid" value="">
</font></b>
</td>
</tr>
<tr width="80%">
<td width="40%">
<b><font face="Arial" size="2">User </font></B></td>
<td width="40%">
<input type="text" name="user" size="12" style="border-style: solid" value="">
</font></b></td>
</tr>
<tr width="80%">
<td width="40%">
<b><font face="Arial" size="2">Password </font></B></td>
<td width="40%">
<input type="password" name="password" size="25" tabindex="20" style="border-style: solid" width="12" value="">
</font></b></td>
</tr>
<tr width="80%">
<td width="40%">
<b><font face="Arial" size="2">Section code </font></b></td>
<td width="40%">
<select size="1" name="section_code" tabindex="9"
style="border-style: solid">
<%@ include file="section.txt" %>
-----------------
Secound question:
// inclided simple .txt file here
// what if new item get enlisted in the database , we have to countinuesly update this .txt file ? so we head for creating simple beans class for retriving values
then displaying in the SELECT box
// we dont know how to do it.
-----------------
//other html tags //
----------------at end -----------------
<input type="Submit" value="Submit" name="B1" > </td>
<td width="40%">
<input type="reset" value="Reset" name="B2"></td>
<%
String action=request.getParameter("Submit");
if(action!=null && action.equals("Submit"))
{
try{
String idcode=request.getParameter("idcode");
String user=request.getParameter("user");
String password=request.getParameter("password");
String seccode=request.getParameter("section_code");
String Category=request.getParameter("Category");
String BCategory=request.getParameter("BCategory");
String Bheads=request.getParameter("Bheads");
String OtherCategory=request.getParameter("OtherCategory");
String email=request.getParameter("email");
String day=request.getParameter("day");
String month=request.getParameter("month");
String year=request.getParameter("year");
String Dob=day+"/"+month+"/"+year;
String day1=request.getParameter("day1");
String month1=request.getParameter("month1");
String year1=request.getParameter("year1");
String Doj=day1+"/"+month1+"/"+year1;
registerbn.setIdcode("idcode");
registerbn.setUser("user");
registerbn.setPassword("password");
registerbn.setSec_code("seccode");
registerbn.setCategory("Category");
registerbn.setBut_Category("BCategory");
registerbn.setBut_heada("Bheads");
registerbn.setOther_Category("OtherCategory");
registerbn.setemail("email");
registerbn.setDob("Dob");
registerbn.setDoj("Doj");
registerbn.saveData();
/// saveData() is the one method where we are wrintn query to insert in to database//
}catch(Exception ex)
{
out.println("ERROR :has occured ");
}
}
%>
</table>
</table>
</table>
</form>
</td>
</tr>
<jsp include page="Footer.jsp" flush="true"/>
 
pie. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic