
I got Login By this code i want to login by validating with combobox....The link which you send its without combobox.i m unable to get login by verifying with combo box..Ex banglore if i select it need to validate username and pass word with place bangalore....please help me i dont know how to validate the combobox for diffrent cities please help me by validating with combobox....
<form action="authenticateUserServlet" method="POST">
<table>
<tr><td align="left">Username</td><td><input type="text" name="username" size="20"></td></tr>
<tr><td align="left">Password:</td><td><input type="password" name="password" size="20"></td></tr>
<tr><td align="left">Cities:</td><td><select style=width:180px><option value="bangalore">bangalore</option>value="mangalore">mangalore</option><option value="hma">hma</option></select></td></tr>
<tr><td colspan="2"><input type="submit" value="Login"><input type="reset" Value="Cancel" ></input></td></tr>
</table>
</form>
servlets:-
package myservlets; import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*;
public class authenticateUserServlet extends HttpServlet { @Override public void init(ServletConfig config) throws ServletException { super.init(config); }
protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
response.setContentType("text/html"); PrintWriter pw = response.getWriter(); String name = request.getParameter("username"); String password = request.getParameter("password");
try{ String driver = "org.postgresql.Driver"; Class.forName(driver).newInstance();
Connection con=null; Statement stmt=null;
String url="jdbc:postgresql://192.168.10.32/blrtaxi"; con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/manju","postgres", "password"); stmt=con.createStatement(); String query = "select uname,password from dblogin where uname='"+name+"' and password='"+password+"'"; System.out.println(query); ResultSet rs = stmt.executeQuery(query);
if(rs.next()){
response.sendRedirect("Menu.jsp"); } else{ response.sendRedirect("index.jsp"); } }
catch(Exception e){ System.out.println(e.getMessage()); } } }
I want login username,password and combobox By sessions please help me.... Thanks for reply.
Thanks and Regards Manjunath Surpur
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.