File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes please figure this out.. 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 "please figure this out.." Watch "please figure this out.." New topic
Author

please figure this out..

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
anyone help me sort out this.
i have a search page with 2 input fields name and lastname that generate the next jsp page which displays the matching records and corresponding to them i have given a drop down year menu. Now , on choosing from the year and then clicking on the name the values for that particular year and for that name are generated.
my code is like this:
<%
Connection con=null;
java.sql.Statement stmt=null;
ResultSet rs=null;

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc:mech_iit");
stmt = con.createStatement();
String fname=request.getParameter("fname").toUpperCase();
String lname=request.getParameter("lname").toUpperCase();
String mainquery="";
String subquery="";
int count=0;
String Desg="";

if(!fname.trim().equals(""))
{
subquery=" upper(fname) like '%"+fname+"%'";
}

if(!lname.trim().equals(""))
{
if(subquery.length()>10)
subquery = subquery + " and ";
subquery = subquery + " upper(lname) like '%"+lname+"%'";
}
mainquery="select fname,lname,Desg,user_login from login where "+subquery+"";

rs=stmt.executeQuery(mainquery);
while(rs.next())
{
count++;
fname = rs.getString("fname");
lname = rs.getString("lname");
Desg=rs.getString("Desg");

%>


<form name="form1" method="post">
<table align="center" border=1 cellspacing=3>
<tr>
<tr>
<tr bordercolor="#000000">
<td bgcolor="#FFFFCC" value="name"><a href ="my_page.jsp?user_login=09090"><%=fname+" "+lname %></a></td>
<td bgcolor="#FFFFCC" value="desg"><%=Desg%></td>
</tr>
<td bgcolor="#FFFFCC"> Year </td>
<td align="middle" bgcolor="#FFFFCC" width="52%">
<select name="year">
<option value="01">2003</option>
<option value="02">2002</option>
<option value="04">2000</option>
<option value="05">1999</option>
</select>
</td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
<%
}
if(count==0)
{
{
out.println("<p><b> No Record Found</b></p>");
}
}
}



catch(Exception e)
{
System.out.println(e);
}
%></table>

Wanted to know that in the next page where the user records are generated how do i display the users records on clicking on his name.
thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: please figure this out..