Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to make multi user login page

843840Jul 9 2008 — edited Jul 9 2008
hi..
i had made a login page in tomkat 5.0 using my sql..its working fine..but i want to make different type of users who will go to different dashboards..first i have used a login page then connecting it to a jsp page which redirect it to the valid dashboard..i had also made two type of databases for different users..how will i direct to specific page after authentication plz. help me..
my code for connecting mysql is.
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


</head>

<body>
<%@ page import="java.sql.*" %>
<%
String username=request.getParameter("user");
String password=request.getParameter("pwds");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","Nirjarashmi");

Statement stmt=con.createStatement();
String vsql="select * from login where uname='"+username+"' and pwd='"+password+"'";


ResultSet rs=stmt.executeQuery(vsql);
if(rs.next())

response.sendRedirect("02_dashboard_welcome.jsp");


else
out.println("Wrong username or password");
}catch(ClassNotFoundException e)
{
out.println(e);
}

%>
</body>
</html>

thanx
gyan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 6 2008
Added on Jul 9 2008
4 comments
327 views