Kox Williams

Greenhorn
+ Follow
since Jan 31, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kox Williams

Hi,
    I am new to JSP. I tried to develop an application in JSP taking help of some examples from the net.I am using netbeans 7.4,mysql 5.6.19 and tomcat 7.0.41.0.But i get stuck to the very first part.The login part of the application.When I try to log on from index.jsp, the welcome.jsp should load. But instead of that the google page is loading.I have 4 java files under my package Admin.java, DatabaseConnector.java, LoginWorker.java and Result.java.
I have the jsp files namely index.jsp,login.jsp and welcome.jsp. The codes of these jsp files are

index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>JSP</title>
   </head>
   <body bgcolor="cyan">
       <form method =post action="login.jsp">
   <center>
       <h1>*****Student Information System*****</h1>
       </center>
   <br>
   <br>
   <h3>Login here</h3>
   Username :<input type="text" name="user"><br><br>
   Password :<input type="password" name="password"><br><br>
   <input type="submit" value="Login">   <input type="submit" value="Reset">
   </form>    
   </body>
</html>

login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="com.mypackage.*"%>
<!DOCTYPE html>
<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>JSP Page</title>
   </head>
   <body>
       <%
           Admin a = new Admin();
           a.username = request.getParameter("user");
           a.password = request.getParameter("password");
           String result =LoginWorker.checkLogin(a);
           
           if(result.equals(Result.SUCCESS))
           {
               response.sendRedirect("welcome.jsp");
           }
           else if(result.equals(Result.ACCESS_DENIED))
           {
               response.sendRedirect("index.jsp");
           }
           else
           {
               response.sendRedirect("https://www.google.co.in");
           }
           %>
   </body>
</html>

welcome.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title>JSP</title>
   </head>
   <body bgcolor="cyan">
     <center>
         <h1>*****Student Information System*****</h1>
         </center>
         <br>
         <br>
       <h3>Welcome Admin!</h3>
       
   </body>
</html>

I have a database named as mydb where there is a table named user having username is admin and password is admin@123. So, in the code where I should make change to load the welcome.jsp page. Expecting a reply from you. Thanking you

With regards
Kox
7 years ago
JSP