Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners login controller.servlet file.. (good coding stuff for reference)
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


chandra
login controller.servlet file.. (good coding stuff for reference)
0 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners


package com.tcs.ilp.controller;

import java.io.*; import java.util.*; import com.tcs.ilp.model.*; import java.sql.*; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import javax.servlet.RequestDispatcher; /** * Servlet implementation class LoginController */ public class LoginController extends HttpServlet { private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#HttpServlet()
 */
public LoginController() {
    super();
    // TODO Auto-generated constructor stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub

  try{

  ArrayList<String> x=new ArrayList<String>();

  String uname=request.getParameter("uname");

  System.out.println(uname);
  String upass=request.getParameter("upass");
  System.out.println(upass);

  HttpSession session=request.getSession();
  session.setAttribute("uname",uname);
  session.setAttribute("upass",upass);

  Connection conn=Create_Connection.conOpen(); 
  System.out.println("Hello");
  int u=LoginDAO.chk_user(conn,uname,upass);
  System.out.println(u);
  if(u==1)
  {
     System.out.println("yaya");
     x=LoginDAO.getDetails(conn,uname,upass);    

     String id=x.get(0);
     String role=x.get(1);

     //System.out.println(x.get(0));
     //System.out.println(x.get(1));

    session.setAttribute("id", id);
    session.setAttribute("role", role);


    if(role.equals("retailer"))
    {
        session.setAttribute("id", id);
        session.setAttribute("role", role);
        RequestDispatcher disp = request.getRequestDispatcher("Retailer_home.jsp");
        disp.forward(request,response);
    }

    if(role.equals("manager"))
    {
        session.setAttribute("id", id);
        session.setAttribute("role", role);
        RequestDispatcher disp = request.getRequestDispatcher("manager_home.jsp");
        disp.forward(request,response);
    }    

    if(role.equals("admin"))
    {
        session.setAttribute("id", id);
        session.setAttribute("role", role);
        RequestDispatcher disp = request.getRequestDispatcher("header.html");
        disp.forward(request,response);
    }
  }
  }
  catch(Exception e) {}
}

}


Advertisement
View Answers

Related Tutorials/Questions & Answers:
login controller.servlet file.. (good coding stuff for reference)
login controller.servlet file.. (good coding stuff for reference)  package com.tcs.ilp.controller; import java.io.*; import java.util.*; import com.tcs.ilp.model.*; import java.sql.*; import java.io.IOException; import
view jsp file (reference file). is the way of coding good ?
view jsp file (reference file). is the way of coding good ?  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> View Retailer <%@ page import="com.tcs.ilp.*" %>
Advertisements
login dao file for referece (source code for reference)
login dao file for referece (source code for reference)  <!DOCTYPE...;body id="login-bg"> <!-- Start: login-holder --> <div id="login-holder"> <!-- start logo --> <div id="logo-login">
coding for login page
coding for login page  coding for login page
Login coding for gettin friends details
Login coding for gettin friends details  login codin in servlet?   Please visit the following link: Login Application
RetController.java (do get) (my file for reference for a test.. IS LOGIC good Enough ?
RetController.java (do get) (my file for reference for a test.. IS LOGIC good Enough ?   try { Connection conn=Create_Connection.conOpen(); System.out.println(conn); String submit
login
login  How to create login page in jsp
login
login  How to create login page in jsp
login
login  login page display an error showing failure to login even when the correct information is entered
login
login  how to login admin and user with the same fields(name & password) in single login page while the table for admin and user is seprate in database(mysql) please provide me solution
login
login  i want to now how i can write code for form login incolude user and password in Jcreator 4.50   Hello Friend, Visit Here Thanks
login
java.awt.event.*; class Login { JButton SUBMIT; JLabel label1,label2; final JTextField text1,text2; Login() { final JFrame f=new JFrame("Login Form...(); ResultSet rs=st.executeQuery("select * from login where username='"+value1
login
login  how to create login page in jsp   Here is a jsp code that creates the login page and check whether the user is valid or not. 1...;tr><td></td><td><input type="submit" value="Login">
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
login
login  i am doing the project by using netbeens.. it is easy to use the java swing for design i can drag and drop the buttons and labels etc.. now i want the code for login.. i created design it contains the field of user name
create login page using data from text file
create login page using data from text file  I want to create login page using data store in textfile(data submit from regiter page to textfile) using jsp and servlet. Thanks
Direct jsp coding for gmail login page and to open mail
Direct jsp coding for gmail login page and to open mail  DEAR SIR, i'm urgently in need of jsp coding to create login page of gmail and to open mail
coding for deleting file
coding for deleting file  coding for deleting file
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
Login Form
Login Form  I have 8 jsp pages.Each of them has three columns:Left... of +,on clicking which a login form appears. Only the middle column is different for each of the page. How to write a code for login authentication so
Login Form
Login Form  I have 8 jsp pages.Each of them has three columns:Left... of +,on clicking which a login form appears. Only the middle column is different for each of the page. How to write a code for login authentication so
login box
login box  class file for password and conform password and how it connected to database
login page
login page  code for login page
login-logout
login-logout  how to do login and logout using session in php
login page
login page  How to login as different user in php
Login page
Login page  how to create Login page in java
LOGIN ERROR
LOGIN ERROR  ERROR SCRIPT: LOGIN FAILED", $_SESSION['login fail']='0',}?> Ty Team
RetDAO.java (part1) ..reference. Is this logic good?
RetDAO.java (part1) ..reference. Is this logic good?  public static int searchDelete(Connection conn,String ret_id) throws Exception { //System.out.println(ret_id); st=conn.createStatement
RetDAO.java (part1) ..reference. Is this logic good?
RetDAO.java (part1) ..reference. Is this logic good?  public static int searchDelete(Connection conn,String ret_id) throws Exception { //System.out.println(ret_id); st=conn.createStatement
 

 

 

DMCA.com