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

 
 


chandra
login controller.servlet file.. (good coding stuff for reference)
0 Answer(s)      11 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) {}
}

}

View Answers









Related Pages:
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.*" %>
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">
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
coding for login page
coding for login page  coding for login page
Login Form
to accessing data. E-mail's login are very  good example... Login Form       Login form in struts: Whenever you goes to access data from
login box
login box  class file for password and conform password and how it connected to database
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 application - Struts
login application  Can anyone give me complete code of user login application using struts and database?  Hello, Here is good example of Login and User Registration Application using Struts Hibernate and Spring
iphone login screen
iphone login screen  Hi i need solution of below question if any one...  not  be  in  the  code  ,it  should  either   be   in   an   external   file   (plist...  Mode       The   App   will   begin   with   the   Login   Screen
login
login  login page display an error showing failure to login even when the correct information is entered
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
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">
need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import javax.swing.*; import java.applet.*; import java.awt.*; import java.util.*; import
need a login applet in java
need a login applet in java  i'm java beginner. Can some java master teach me how to write a login applet? combine with my coding import javax.swing.*; import java.applet.*; import java.awt.*; import java.util.*; import
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
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
Struts 2.1.8 Login Form
in the struts.xml file: <!-- Login Form Configuration --> <action name... Struts 2.1.8 Login Form      ... to validate the login form using Struts 2 validator framework. About the example
Spring MVC Login Example
"User Login Here" that will be linked "login.html" file...: The success.jsp file is contain code for display login success and contain... login application. In this file we will declared two private variable username
Login authentication & mysql - Java Beginners
Login authentication & mysql  Hi , Could you guide or provide sample coding for the following scenerio. I need to code authentication for user login I need to create a user account which is the user can register
Login form
Login Form with jsp      ... of login form will really help to understand jsp page. In this  example we... are going to insert the data in the login form which will be displayed onto
Struts 2 Login Application
Struts 2 Login Application       Developing Struts 2 Login Application In this section we are going to develop login application based on Struts 2 Framework. Our current login application
RichFaces: Login & Registration Application:
RichFaces: Login & Registration Application      Login and Registration is one of the most required module of any project. This tutorial explains how to implement login and registration
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
PHP MySQL Login Form
Login Form using PHP and MySQL: In any website generally it is mandatory to have a login form to keep your data secure. In this regard we need to have... will study how to create a login form, connect with the database server and login
Login/Logout With Session
Login/Logout With Session       In this section, we are going to develop a login/logout application with session...; Create an action mapping in the struts.xml file. Here is the code to be added
how to login form through spring dao module
how to login form through spring dao module  here i want to chek user details in database through form by using spring dao module.please give me some reference example to me
getting classnotfound exception while running login application
getting classnotfound exception while running login application  hi... in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Cannot resolve reference... running the Login Application   Have a look at the following link: Spring
Example of login form validation in struts2.2.1framework.
Example of login form validation in struts2.2.1 framework. In this example, we will introduce you to about the login form validation in struts2.2.1 framework. Our login form validation example does not validate the user against
Role based login ..Need the concepts.. - JavaMail
Role based login ..Need the concepts..  Role based login how can i do... points remember "login.jsp" 1)Code have two file "login.jsp" and "welcome.jsp...". Login Name Admin Employee Login Name
About Struts 2.2.1 Login application
.style1 { margin-left: 80px; } About Struts2.2.1 login application In the most common login application there is  login form which is takes... / browser. To create an login application At first create a login page in JSP
Struts Hibernate Spring - Login and User Registration - Hibernate
Struts Hibernate Spring - Login and User Registration  Hi All, I fallowed instructions that was given in Struts Hibernate Spring, Login and user... users manually on the database side and see if I could login using those
Login Form using Ajax
Login Form using Ajax       This section provides you an easy and complete implementation of login form using the Ajax (DOJO).  Lets develop a login application using Ajax
JSF Validation In Login Application
for the resultforfail.jsp file: Login Failed! Here is the code for the resultforsuccess.jsp file: Login Successful! Here...:view> <html> <head><title>JSF Simple Login Example<
JSF Simple Login Application
for the resultforfail.jsp file: Login Failed! Here is the code for the resultforsuccess.jsp file: Login Successful! Here...:view> <html> <head><title>JSF Simple Login Example<
Admin and User Login JSP - JSP-Servlet
Admin and User Login JSP  Respected Sir, I am R.Ragavendran.. i need a JSP based program immediately.. In the home page, there must be a login... somewhat urgent too.. Plz send me the coding ASAP.. Thanks/Regards
login page
login page  code for login page
Struts 2 Login Form Example
Struts 2 Login Form Example tutorial - Learn how to develop Login form... you can create Login form in Struts 2 and validate the login action.... Let's start developing the Struts 2 Login Form Example Step 1
Creating Login Page In JSF using NetBeans
and click. 3. Enter JSP File Name (login, for this example) when New JSP File... Creating Login Page In JSF using NetBeans  ... illustrates you how to create a login form in JSF using NetBeans. To create the jsp page
Login Authentication in JSP
String page="selectbox.jsp"; Full code for Servlet File "... and place this class file into Web-Inf/classes folder Do entry of servlet into web.xml Create and Save JSP file selectbox.jsp Start and deploy Tomcat Server

Ask Questions?

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.