The Artima Developer Community
Sponsored Link

Java Answers Forum
coding error-can nay one help me

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
sunitha

Posts: 1
Nickname: sunflower
Registered: Jan, 2003

coding error-can nay one help me Posted: Jan 31, 2003 6:48 AM
Reply to this message Reply
Advertisement
i have a login page in which validation is done by a bean

action is done by a servlet. There is another main controller servlet which redirect according to the page user requested. now the problem is with the login servlet

can any on help me....


///*
//* CSRLoginServlet.java
// *
// * Created on January 29, 2003, 12:21 PM
package serveltspkg;
import beans.*;
import java.io.*;
//import java.net.*;
import java.lang.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
*
* @author surag
* @version
*this servlet is the controller of the csr login page
*if the login is correct the user is redirected to the login where ssn and pin entered
*otherwise user redirected to the csr welcome page
*/



public class CSRLoginServlet extends HttpServlet implements SingleThreadModel
{

public void doGet(HttpServletRequest request,HttpServlet response) throws ServletException


{
handlerequest( request, response);

}

public void doPost( HttpServletRequest request,HttpServlet response) throws ServletException


{

handlerequest( request, response);

}

public void handlerequest( HttpServletRequest request, HttpServletResponse response) throws ServletException
{

try

{
String action = request.getParameter("action");
System.out.print("Servlet action=" +action+ "HELLO world");
HttpSession session = request.getSession(false);
if ( session==null)
{

System.out.println("session is null");
return;
}

else

{
System.out.println("Login session is not null");
}


String userid = request.getParameter("userid").trim();

String pwd = request.getParameter("pwd").trim();


System.out.println(" this is userid"+ userid+pwd);

beans.csr.CSRLoginFormTempBean csrbean=(beans.csr.CSRLoginFormTempBean)session.getAttribute("csr");

if ( csrbean ==null)
{
System.out.println("bean is null");
return;
}

else
{
System.out.println("bean is not null");

if( action.equals("Proceed"))
{

//csrbean.setUserid(userid);
//csrbeans.setpwd(pwd);
int retval = csrbean.validate();
System.out.println("hello"+ retval);


if ( retval==0)


{ session.setAttribute("gpageName", "/CSRWelcome");

request.getRequestDispatcher(response.encodeURL("/Login")).forward(request,resp onse);


}

else


{ session.setAttribute("gpageName", "/CSRWelome");

request.getRequestDispatcher(response.encodeURL("/CSRWelcome")).forward(request ,response);

}

}



catch ( Exception ex)

{
ex.printStackTrace();

throw new ServletException( " An error occured handling request" ,ex);


}




}
}

Topic: HTTPURLConnection and certificate Previous Topic   Next Topic Topic: parsing

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use