-
Notifications
You must be signed in to change notification settings - Fork 0
/
alphorder.java
70 lines (70 loc) · 2.3 KB
/
alphorder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class alphorder extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
Connection con=null;
Statement stmt=null;
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:sri","scott","tiger");
stmt=con.createStatement();
String alph=req.getParameter("alphsrh");
String qry="select title,author,pname,subject,rate from books where title like '"+alph+"%'";
ResultSet rs=stmt.executeQuery(qry);
pw.println("<pre><b><font size=6>"+"\t\t\t"+"<u>"+"ALPHBATICAL LIST OF BOOKS"+"</pre></u></b></font>");
pw.println("<form action=\"http://localhost:8080/servlet/addcart\" method=post>");
pw.println("<br><font size=4><b>");
pw.println("<pre>"+"TITLE\t\t\t\tAUTHOR\t\t\t\tPUBLISHER NAME\t\t\t SUBJECT\t\t\tRATE"+"</pre></font></b>");
//pw.println("<pre><select name=selectbk size=5>");
while(rs.next())
{
String t=rs.getString(1);
int len=t.length();
len=40-len;
String s=" ";s=s.concat(t);
len=t.length();
for(int i=len;i<40;i++)
s=s.concat(".");
t=rs.getString(2);
s=s.concat(t);
len=t.length();
for(int i=len;i<40;i++)
s=s.concat(".");
t=rs.getString(3);
len=t.length();
s=s.concat(t);
for(int i=len;i<40;i++)
s=s.concat(".");
t=rs.getString(4);
s=s.concat(t);
len=t.length();
for(int i=len;i<40;i++)
s=s.concat(".");
t=rs.getString(5);
s=s.concat(t);
pw.println("<pre><option>"+s+"</option><br></pre>");
}
pw.println("<pre> Selected items</pre>");
pw.println("<pre><label> Item name: </label><input type=text name=txtinm></pre>");
pw.println("<pre><label> Item Quantity: </label><input type=text name=txtq></pre>");
pw.println("<pre><label> Item type: </label><input type=text name=txtr></pre>");
pw.println("<pre><label> Please enter H/h for Hardware S/s for Software M/m for Music B/b for Books</pre></label>");
pw.println("<font size=3><br><br><input type=submit value=Add_to_Cart></font></form>");
}
catch(ClassNotFoundException e){}
catch(SQLException e){}
finally
{
try
{ if (con!=null)
con.close();
}catch(SQLException e){}}
}
}