Help with JSP, session, login, JDBC.

This is the template login.jsp file I have at the moment.
<%@ page errorPage="errorPage.jsp" %>
<%
  String login = (String)request.getParameter("loginname");
  if (login == null || login.equals("")) {
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
<HEAD>
<TITLE>Login Page</TITLE>
<STYLE>
<!--
font.loginhead {
  font-family: Arial,Helvetica,sans-serif;
  font-size:12pt; font-weight: 600; color: #000000;
font.loginform {
  font-family: Arial,Helvetica,sans-serif;
  font-size:10pt; font-weight: 600; color: #ffffff;
-->
</STYLE>
</HEAD>
<BODY>
<jsp:include page="debug.jsp" flush="true" />
<CENTER>
<FONT CLASS="loginhead">
LOGIN REQUIRED:
</FONT>
<BR>
<FORM NAME="loginform" METHOD=post>
<TABLE BGCOLOR=#990022 BORDER=0 CELLPADDING=5 CELLSPACING=0>
<TR><TD ALIGN=right>
<FONT CLASS="loginform">
Login Name:
</FONT>
</TD><TD ALIGN=left>
<FONT CLASS="loginform">
<INPUT TYPE=text NAME="loginname" SIZE=10>
</FONT>
</TD></TR>
<TR><TD ALIGN=right>
<FONT CLASS="loginform">
Password:
</FONT>
</TD><TD ALIGN=left>
<FONT CLASS="loginform">
<INPUT TYPE=password NAME="loginpassword" SIZE=10>
</FONT>
</TD></TR>
<TR><TD COLSPAN=2 ALIGN=center>
<FONT CLASS="loginform">
<INPUT TYPE=SUBMIT VALUE="Login">
</FONT>
</TD></TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
<%
  } else {
   Checking against database that username and password are correct.
    session.putValue("login", login);
    session.setMaxInactiveInterval(600);
    String loginpoint
       = (String)session.getValue("loginpoint");
    if (loginpoint == null) {
      StringBuffer defaultpoint = new StringBuffer();
      defaultpoint.append(request.getScheme())
                  .append("://")
                  .append(request.getServerName())
                  .append("/");
      loginpoint = defaultpoint.toString();
    } else {
      session.removeValue("loginpoint");
    response.sendRedirect(loginpoint); 
  }I know as much as how connect to the database, create a statement and check to see if the username and password are correct, I dont know how to actually take what the user has typed in and put it in an mysql query. I have an idea that maybe I can convert Login and Loginpassword to Strings but I don't know how to do this.
This is how I plan to connect to the database above
//here I need to have login and loginpasword in separate Strings so I can use them in a query.
Connection connection;
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("jdbc:mysql://localhost/Users");
Statement statement=connection.createStatement();
String qry="select PassWord from customers where UserName='"+stringLogin+"'";
ResultSet rs= statement.executeQuery(qry);In my login.jsp file above I don't understand the following code, and why it is needed. Can someone explain please.
session.putValue("login", login);
    session.setMaxInactiveInterval(600);
    String loginpoint
       = (String)session.getValue("loginpoint");
    if (loginpoint == null) {
      StringBuffer defaultpoint = new StringBuffer();
      defaultpoint.append(request.getScheme())
                  .append("://")
                  .append(request.getServerName())
                  .append("/");
      loginpoint = defaultpoint.toString();
    } else {
      session.removeValue("loginpoint");
    response.sendRedirect(loginpoint); 
  }Hope you can understand what I'm trying to explain what my problems are.

Im not sure what your exact question is. However, I can
throw a few things out there.
1) You need an action to handle the form request
<FORM NAME="loginform" METHOD=post ACTION="login.jsp">2) Then get the username and password from the request
String uname = (String)request.getParameter("loginname");
String pass = (String)request.getParameter("loginpassword");3)Then you can just add them to the query string
String qry="select PassWord from customers where UserName='"+uname+"'";4) Also check for valid password
ResultSet rs= statement.executeQuery(qry);
if(rs.next()) {
    String p = res.getString("PassWord");
         if (p.equals(pass)) {
            //valid user
            session.setAttribute("valid_user", "true");
            // now you can get valid_user from session at top of login.jsp
}5) I cant find where loginpoint is set in the session, but the idea
of the code below appears to be the logic of where to direct the user
which I think would be dependent upon the validation of the user.
session.putValue("login", login);
    session.setMaxInactiveInterval(600);
    String loginpoint
       = (String)session.getValue("loginpoint");
    if (loginpoint == null) {
      StringBuffer defaultpoint = new StringBuffer();
      defaultpoint.append(request.getScheme())
                  .append("://")
                  .append(request.getServerName())
                  .append("/");
      loginpoint = defaultpoint.toString();
    } else {
      session.removeValue("loginpoint");
    response.sendRedirect(loginpoint); 
  }You might try splitting the login into two pages to start out if you are having
some difficulty.

Similar Messages

  • Help with jsp session validation

    i've build up a page that only users wil 'administrator' as the session is variable can access. if they don't they will be directed to the login page.
    However, I'm getting a null pointer exception.
    my code is as follows:
    <%@ page import="java.io.*"%>
    <%
         if (session.getAttribute("id").equals(null) || !(session.getAttribute("id").equals("administrator")))
              response.sendRedirect("adminlogin.htm");
    %>
    Error Message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException
    root cause
    java.lang.NullPointerException
    any pros please help? i know it's something to do with my jsp session validation. thanks in advance.

    one more thing, with regrads to the solution evnafets provided. I tried it out on all my pages that requires administrator rights and found that the code only redirects when it's not expecting any parameters. Else, it just display an error message there. Is there a way around this? Or I should let let my end user suffer?
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:534)
    root cause
    java.lang.NullPointerException
         at org.apache.jsp.view_jsp._jspService(view_jsp.java:177)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:534)

  • Need help with JSP - Session Bean scenario

    I have massive problems with a simple JSP <--> Statefull Session Bean scenario with Server Platform Edition 8.2 (build b06-fcs)
    What I do is generating a Collection in session bean returning it to JSP
    and giving the List back to Session Bean.
    A weird exception happens when giving the List back to Session Bean
    (see Exception details below)
    The same code runs without any trouble on Jboss Application Server 4.0.3
    Any help would be great!
    Please see code below
    Statefull Session Bean
    <code>
    package ejb;
    import data.Produkt;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Iterator;
    import javax.ejb.*;
    * This is the bean class for the WarenkorbBean enterprise bean.
    * Created 17.03.2006 09:53:25
    * @author Administrator
    public class WarenkorbBean implements SessionBean, WarenkorbRemoteBusiness, WarenkorbLocalBusiness {
    private SessionContext context;
    // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click the + sign on the left to edit the code.">
    // TODO Add code to acquire and use other enterprise resources (DataSource, JMS, enterprise bean, Web services)
    // TODO Add business methods or web service operations
    * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
    public void setSessionContext(SessionContext aContext) {
    context = aContext;
    * @see javax.ejb.SessionBean#ejbActivate()
    public void ejbActivate() {
    * @see javax.ejb.SessionBean#ejbPassivate()
    public void ejbPassivate() {
    * @see javax.ejb.SessionBean#ejbRemove()
    public void ejbRemove() {
    // </editor-fold>
    * See section 7.10.3 of the EJB 2.0 specification
    * See section 7.11.3 of the EJB 2.1 specification
    public void ejbCreate() {
    // TODO implement ejbCreate if necessary, acquire resources
    // This method has access to the JNDI context so resource aquisition
    // spanning all methods can be performed here such as home interfaces
    // and data sources.
    // Add business logic below. (Right-click in editor and choose
    // "EJB Methods > Add Business Method" or "Web Service > Add Operation")
    public Collection erzeugeWarenkorb() {
    //TODO implement erzeugeWarenkorb
    ArrayList myList = new ArrayList();
    for (int i=0;i<10;i++)
    Produkt prod = new Produkt();
    prod.setID(i);
    prod.setName("Produkt"+i);
    myList.add(prod);
    return myList;
    public void leseWarenkorb(Collection Liste) {
    //TODO implement leseWarenkorb
    Iterator listIt = Liste.iterator();
    while(listIt.hasNext())
    Produkt p = (Produkt)listIt.next();
    System.out.println("Name des Produktes {0} "+p.getName());
    </code>
    <code>
    package data;
    import java.io.Serializable;
    * @author Administrator
    public class Produkt implements Serializable {
    private int ID;
    private String Name;
    /** Creates a new instance of Produkt */
    public Produkt() {
    public int getID() {
    return ID;
    public void setID(int ID) {
    this.ID = ID;
    public String getName() {
    return Name;
    public void setName(String Name) {
    this.Name = Name;
    </code>
    <code>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="java.util.*"%>
    <%@page import="data.*"%>
    <%@page import="javax.naming.*"%>
    <%@page import="javax.rmi.PortableRemoteObject"%>
    <%@page import="ejb.*"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <h1>Online Shop Warenkorb Test</h1>
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    <%
    Context myEnv = null;
    WarenkorbRemote wr = null;
    // Context initialisation
    try
    myEnv = (Context)new javax.naming.InitialContext();
    /*Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
    //env.put(Context.PROVIDER_URL, "jnp://wotan.activenet.at:1099");
    env.put(Context.PROVIDER_URL, "jnp://localhost:1099");
    env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    myEnv = new InitialContext(env);*/
    catch (Exception ex)
    System.err.println("Fehler beim initialisieren des Context: " + ex.getMessage());
    // now lets work
    try
    Object ref = myEnv.lookup("ejb/WarenkorbBean");
    //Object ref = myEnv.lookup("WarenkorbBean");
    WarenkorbRemoteHome warenkorbrhome = (WarenkorbRemoteHome)
    PortableRemoteObject.narrow(ref, WarenkorbRemoteHome.class);
    wr = warenkorbrhome.create();
    ArrayList myList = (ArrayList)wr.erzeugeWarenkorb();
    Iterator it = myList.iterator();
    while(it.hasNext())
    Produkt p = (Produkt)it.next();
    %>
    ProduktID: <%=p.getID()%><br></br>Produktbezeichnung:
    <%=p.getName()%><br></br><%
    wr.leseWarenkorb(myList);
    catch(Exception ex)
    %><p style="color:red">Onlineshop nicht erreichbar</p><%=ex.getMessage()%>
    <% }
    %>
    </body>
    </html>
    </code>
    the exception
    CORBA MARSHAL 1398079745 Maybe; nested exception is: org.omg.CORBA.MARSHAL: ----------BEGIN server-side stack trace---------- org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe at com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:8101) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1013) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:873) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_abstract_interface(CDRInputStream_1_0.java:863) at com.sun.corba.ee.impl.encoding.CDRInputStream.read_abstract_interface(CDRInputStream.java:275) at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectDelegate(IIOPInputStream.java:363) at com.sun.corba.ee.impl.io.IIOPInputStream.readObjectOverride(IIOPInputStream.java:526) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:333) at java.util.ArrayList.readObject(ArrayList.java:591) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.corba.ee.impl.io.IIOPInputStream.invokeObjectReader(IIOPInputStream.java:1694) at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1212) at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400) at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:330) at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:296) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034) at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259) at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl$14.read(DynamicMethodMarshallerImpl.java:333) at com.sun.corba.ee.impl.presentation.rmi.DynamicMethodMarshallerImpl.readArguments(DynamicMethodMarshallerImpl.java:393) at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121) at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:648) at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:192) at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1709) at com.sun.corba.ee.impl.protocol.SharedCDRClientRequestDispatcherImpl.marshalingComplete(SharedCDRClientRequestDispatcherImpl.java:155) at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:184) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:129) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150) at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source) at ejb._WarenkorbRemote_DynamicStub.leseWarenkorb(_WarenkorbRemote_DynamicStub.java) at org.apache.jsp.index_jsp._jspService(index_jsp.java:122) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:517) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475) at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371) at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281) at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83) Caused by: java.lang.ClassNotFoundException ... 69 more ----------END server-side stack trace---------- vmcid: SUN minor code: 257 completed: Maybe

    Hi,
    I have found a way out by passing the reference of my EJB in the HttpSession object and using it inside the javabean..

  • Need help with the session state value items.

    I need help with the session state value items.
    Trigger is created (on After delete, insert action) on table A.
    When insert in table B at least one row, then trigger update value to 'Y'
    in table A.
    When delete all rows from a table B,, then trigger update value to 'N'
    in table A.
    In detail report changes are visible, but the trigger replacement value is not set in session value.
    How can I implement this?

    You'll have to create a process which runs after your database update process that does a query and loads the result into your page item.
    For example
    SELECT YN_COLUMN
    FROM My_TABLE
    INTO My_Page_Item
    WHERE Key_value = My_Page_Item_Holding_Key_ValueThe DML process will only return key values after updating, such as an ID primary key updated by a sequence in a trigger.
    If the value is showing in a report, make sure the report refreshes on reload of the page.
    Edited by: Bob37 on Dec 6, 2011 10:36 AM

  • PLease Help !Jsp Session expired when open Window with "_blank" atributte

    PLease please Help me!
    Hi ,
    I have a problem
    First , all my pages when load evaluate if session exists .
    If not exists session
    this page redirect other page (page_expired.jsp)
    this works correctly ... but
    when page01.jsp open page02.jsp from :
    <form action='page02.jsp' target ="_self"> - >works correctly (load on the same page ..)
    but when :
    <form action='page02.jsp' target ="_blank"> -> this redirect page_expired.jsp
    why this ??
    Sometimes work and Sometimes not work...
    but now it does not work
    Excuse my english not is goog...
    Greetings From Lima - Peru

    Hi
    This problem ocurred when testing on my server of testing(this is in my office) ,
    but when test in the server machine of my house this work!!! great! ,
    not appear session expired.!!
    this theme of configuration ??
    if is ths ?
    what configure ?
    Please Help Me .
    I am using EASERVER 5.2 with JSP
    Bye! Greetings From Lima Per�

  • Help with some java login code

    hey,
    I am a new member but used to visit the site regularly. I am undergoing a java project and I cannot seem to get my head around how to code when users log in, there name must appear at the top of each page they visit.
    User enters name into a text box. Do I use getter and setter methods? any bit of help would be of some advantage to me.
    Thanks for your time and I'll help with anyone else who is stuck.

    if JSP or servlet use Session...
    if you are using frame you have to consider... which frame is a top parent. that top frame will have the set and get method.. for you to set and retrieve the user name.. bear in mind that different object will have different user...
    so you have to play fair game ...hehehehe :-)

  • URGENT help with JSP

    Any help with this will be really appreciated. I'm new to programming.
    If I search for an ssn in a database, I want to view all records relating to that ssn. However, I am getting all the records in the table.
    eg.
    at the prompt for ssn, let's say I enter 111111111
    I would like to see
    111111111 abc xyz etc
    111111111 pdg ppp etc
    however, I am getting
    000000000 utt tui etc
    111111111 tug etg etc
    How do I make limit the search to the ssn I want?
    The related code is below.
    Thanks.
    Java Code
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    if (checkLoginSessionPresent(request, response)) {
    loadTable("/esoladm/TaxView.jsp", request, response);
    else {
    checkLoginSessionRedirect("/esoladm/ESOLAdminMain.jsp", request, response);
    JSP Code
    <% while (MyTaxSuppress != null) { %>             
    <% String sPlanCode = MyTaxSuppress.getPlanCode(); %>
    <% String sSSN = MyTaxSuppress.getSSN(); %>
    <% String sTaxYear = MyTaxSuppress.getTaxYear(); %>
    <% String sDistCode = MyTaxSuppress.getDistCode(); %>
    <% double sGrAmount = MyTaxSuppress.getGrAmount(); %>
    <% String sStmtType = MyTaxSuppress.getStmtType(); %>
    <% boolean bNewSuppress = MyTaxSuppress.getNewSuppress(); %>
    <% String rowID = sPlanCode; %>
    <% rowID += sSSN; %>
    <% rowID += sTaxYear; %>
    <% rowID += sDistCode; %>
    <% rowID += sStmtType; %>
    <% rowID += sGrAmount; %>
    <% System.out.println( "Do While lp exiti" + rowID);%
    <% if (bNewSuppress) { %>
    <% out.println( "<TD> %>
    <% <img BORDER='0' SRC='/esoladm/ESOLNew2.gif' %>
    <% ALT='' WIDTH='50' HEIGHT='20'> </TD >"); %>
    <% } else { %>
    <% out.println( "<TD></TD>"); %>
    <% } %>
    <TD><%= sPlanCode %></TD>
    <TD><%= sSSN %></TD>
    <TD><%= sTaxYear %></TD>
    <TD><%= sDistCode %></TD>
    <TD><%= sGrAmount %></TD>
    <TD><%= sStmyType %></TD>
    <TD><input TYPE="checkbox" name="<%=rowID %>" ></TD>
    <% MyTaxSuppress = MySuppressTaxList.getNext(); %>
    <% } // end of while loop %>

    I don't see anywhere in your code where you conditionally output a tuple from your database. You seem to be outputting everything.
    Maybe you need:
    <% if (sSSN==input_value){ %>
    <TD><input TYPE="checkbox" name="<%=rowID %>" ></TD>
    <% } %>

  • Help with JSP and logic:iterate

    I have some queries hope someone can help me.
    I have a jsp page call request.jsp:
    ====================================
    <%@ page import="java.util.*" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html>
    <body>
       <%@ page import="RequestData" %>
       <jsp:useBean id="RD" class="RequestData" />
       <%Iterator data = (Iterator)request.getAttribute("Data");%>
       <logic:iterate id="element" name="RD" collection="<%=data%>">
          <jsp:getProperty name="RD" property="requestID" />
          <%=element%><br>
       </logic:iterate>
    </body>
    </html>
    And I have the RequestData.java file:
    ======================================
    private int requestID = 1234;
    public int getRequestID() { return requestID; }
    The jsp page display:
    ======================
    0 RequestData@590510
    0 RequestData@5b6d00
    0 RequestData@514f7f
    0 RequestData@3a5a9c
    0 RequestData@12d7ae
    0 RequestData@e1666
    Seems like the requestID is not returned. Does anybody know this?
    I have done the exact one using JSP and servlets, trying to learn using JSP and custom tags. The one with JSP and servlet looks like:
    ============================================
    <%@ page import="RequestData" %>
    <%Iterator data = (Iterator)request.getAttribute("Data");
    while (data.hasNext()) {
       RequestData RD = (RequestData)data.next();
       out.println(RD.getRequestID() );
    }%>

    Oh think I got it...
    but one thing I'm not sure is...
    If I use "<jsp:useBean id="RD" class="RequestData" />", do I still need "<%@ page import="RequestData" %>"?
    I tried without and it gives me error...

  • Help with jsp beans

    Hi ,
    I'm new to beans .Please help me on this. I have 2 jsp pages -trial.jsp and trial2.jsp and a bean class-UserInfo.java
    I'm setting the bean values from trial.jsp and trying to retrieve from trial2.jsp. But the values are coming as null. Can you please help me on this.
    Code of Trial.jsp
    <html>
    <body>
    <form name="beanTest" method="get" action="trial2.jsp">
    <table width="60%">
      <tr>
        <td width="44%">Name</td>
        <td width="56%"><label>
          <input type="text" name="name" id="name">
        </label></td>
      </tr>
      <tr>
        <td>Age</td>
        <td><input type="text" name="age" id="age"></td>
      </tr>
      <tr>
        <td>Occupation</td>
        <td><input type="text" name="occupation" id="occupation"></td>
      </tr>
      <tr>
        <td><label>                
        <jsp:useBean id="person" class="javaUtil.UserInfo" scope="request"/>
    <jsp:setProperty property="*" name="person"/>
    <input type="submit" value="Test the Bean">
    </form>
    </body>
    </html>
    Trial2.jsp
    <form>
    <jsp:useBean id="person" class="javaUtil.UserInfo" scope="request"/>
    Name<jsp:getProperty property="name" name="person"/><br>
    age:<jsp:getProperty property="age" name="person"/><br>
    job:<jsp:getProperty property="occupation" name="person"/><br>
    </form>
    UserInfo.java
    package javaUtil;
    import java.io.Serializable;
    public class UserInfo implements Serializable{
         private static final long serialVersionUID = 1L;
         private String name;
         private int age;
         private String occupation;
         public String getName()
              return this.name;
         public void setName(String name)
              this.name=name;
         public int getAge()
              return this.age;
         public void setAge(int age)
              this.age=age;
         public String getOccupation()
              return this.occupation;
         public void setOccupation(String occupation)
              this.occupation=occupation;
    Please help me.....

    Actually you're probably off on a false trail with jsp:useBean. The more up to date methods use tag libraries (typically JSTL) and access bean attributes using EL, bean expression language. E.g. you put your initial form data into a request attribute called "data" and you put:
    <input type="text" name="property1" value="${data.property1}" ....useBean is no use for binding returned fields from a form. Always remember that your JSP generates HTML and once that HTML is sent to the browser that's it, the JSP has done it's job and finished. Only with JSF, at present, does what you write in your JSP affect the processing of received form data. When you get the form data back you need to "bind" the values from the request back to the bean. A framework like Spring will do this stuff for you, but in a raw Servlet/JSP environment it's up to you.

  • Help with JSP Forward !!!

    I have 3 pages ...1) index.jsp 2) Forward.jsp 3) welcome.jsp
    I have 2 fields in the index.jsp once upon filling & hit submit it has to to go Forward.jsp page...in the Forward.jsp..i have coded only one tag with
    <jsp:forward page="welcome.jsp" />
    I have one question...once the page comes to Forward page...will it display the contents of the Welcome .jsp in the same page itself...or it will go to Welcome.jsp page..
    As i saw it will display the contents of Welcome.jsp page in itself...
    Please let me know...
    Regards
    Gnanesh

    I understand your question only because I have a set up totally identical to yours. The thread Matt suggested does explain the situation (i.e. the server passed control to another page but the client doesn't know that), but doesn't necessarily give a good solution a problem that you may have, and that I do have:
    If the user sees the welcome page, and for some reason decides to "reload", the forward page is re-executed, even though it has done its job. This could be a problem for session management if you specifically don't want that job being done twice in a session. Now you could hack around that, but I'd really rather see a neat solution. Is there one?

  • Help with JSP/Weblogic/Tomcat Discrepencies

    Hi,
              I have something very strange happening. I recently did some JSP stuff on
              WLS60SP1 and all went quite well. I then took those same JSP pages and tried
              them out on the latest release of TOMCAT. I was really impressed that
              everything seemed to be completely transparent and working just fine until
              the following situation:
              When I reference, within a JSP page, an object that has previously been
              added to the request scope that has just been created, but not messed with
              in anyway...meaning all the attributes in this bean have their default
              values set...and they are all Strings with the exception of one Integer
              using this format:
              <%= custVal.getCustomerNumber() %>
              - In WLS, what shows in the text field on the form is nothing, because
              customer number in the custVal object is null (default for a String)..this
              is what I want.
              - In Tomcat, what shows it the word "null".
              ...here is the weird part, by changing from scriptlet references to the
              <jsp:getProperty....> format such as....
              <jsp:getProperty name="custVal" property="customerNumber"/>
              -In WLS, he is still a happy camper and works just fine regardless of how I
              reference the bean
              -In Tomcat, I also get the correct results that I want.
              So, unlike most postings, I found out how to fix it but I would like to know
              why...any ideas?
              Thanks in advance,
              Paul Reed
              www.jacksonreed.com
              object training and mentoring
              Jackson-Reed, Inc. 888-598-8615
              www.jacksonreed.com
              Author of "Developing Applications with Visual Basic and UML"
              http://www.amazon.com/exec/obidos/ASIN/0201615797/jackreedinc/104-0083168-31
              95939
              Author of "Developing Applications with Java
              

              Try http://localhost:7001/HelloWorld.jsp
              "b. patel" <[email protected]> wrote:
              >
              >I need help with running a simple JSP. I created a WLS domain using the
              >WebLogic
              >Configuration Wizard. I am trying to access HelloWorld.jsp which is
              >located under
              >C:\bea\user_projects\wlsdomainex\applications\DefaultWebApp.
              >I type
              >http://localhost:7001/DefaultWebApp/HelloWorld.jsp. I get 404 - Page
              >Not Found
              >Error. The weblogic server starts Succesfully. I am trying this in Win
              >2K environment.
              >
              >I am new to WebLogic. Thanks for your Help in advance.
              >
              

  • Help with JSP and Servlets

    Hi,
    How would I create an editable JSP form from JDBC?
    I know how to retrieve the data from JDBC, but I'm still trying to figure out how to take that table data and format it into a tabluar format that user can make changes to it.
    Thanks,
    Tom
    Message was edited by:
    bztom_33
    Message was edited by:
    bztom_33

    CreateConnection();
    logger.info("Database connection opened in Testimonials");
    String queryText = "LOCK TABLE testimonials WRITE,posting_table WRITE";
    int numOfRows = st.executeUpdate(queryText);
    rs = st.executeQuery(SELECT_QUERY_FROM_TESTIMONIALS);
    logger.info("Query executed postingVeiw");
    String queryText1 = "UNLOCK TABLES";
    int numOfRow = st.executeUpdate(queryText1);
    while(rs.next())
    ClientData client = new ClientData();
    client.setName(rs.getString("name"));
    client.setTestimonial(rs.getString("testimonial"));
    client.setCompany(rs.getString("company"));
    clientList.add(client);
    RequestDispatcher disp = null;
    req.setAttribute("clientlist", clientList);
    String error1 = req.getParameter("");
    disp = req.getRequestDispatcher("testimonial.jsp");
    disp.forward(req,res);
    And call this arraylist from the jsp page
    Cheers
    Varun Rathore

  • Need serious help with JSP + JDBC/Database connection

    Hey all,
    I have to build an assignment using JSP pages. I am still pretty new and only learning through trial and error. I understand a bit now, and I have managed to get a bit done for it.
    I am having the most trouble with a Login Screen. The requirements are that the a form in a webpage has Username/Number and Password, the user clicks Login, and thats about it. The values for the username/number and password NEED to come from the database and I cannot manage to do this. The thing I have done is basically hardcode the values into the SQL statement in the .jsp file. This works, but only for that one user.
    I need it so it checks the username/number and password entered by the user, checks the database to see if they are in it, and if so, give access. I seriously am stuck and have no idea on what to do.
    I dont even know if I have made these JSP pages correct for starters, I can send them out if someone is willing to look/help.
    I have setup 3 other forms required for the assignment and they are reading data from the db and displaying within tables, I need to do this with non-hardcoded values aswell. Im pretty sure I need to use for example 'SELECT .... FROM .... WHERE username= +usrnm' (a variable instead of username="john" , this is hardcoded), I just CANNOT figure out how to go about it.
    Its hard to explain through here so I hope I gave enough info. A friend of mine gave some psuedocode i should use to make it, it seems ok to follow, its just I do not know enough to do it. He suggested:
    get the username and pass from the env vars
    open the db
    make an sql (eg SELECT user, pass FROM users WHERE user = envuser)
    index.jsp points to login.jsp
    login.jsp get the vars you put into index.jsp
    opened the db
    is the query returns nothing - then the user is wrong
    OR if the passwords dont match
    - redirect back to index.jsp
    if it does match
    - set up a session
    - redirect to mainmenu.jsp
    Anyway, thanks for any help you can give.
    -Aaron

    Hi,
    Try this... it may help you...
    mainMenu.jsp
    <html>
    <body>
    <form method="POST" action="login.jsp">
    Username: <input type="text" name="cust_no">
    <p>
    Password: <input type="password" name="password">
    <p>
    <input type="submit" value="LOGIN">
    </form>
    </body>
    </html>
    login.jsp
    <%@ page import="java.io.*, java.sql.*"%>
    <html>
    <body>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:odbc:rocky");
    Statement statement = connection.createStatement();
    String query = "SELECT cust_no, password FROM customers WHERE cust_no='";
    query += request.getParameter("cust_no") + "' AND password='";
    query += request.getParameter("password") + "';";
    ResultSet resSum = statement.executeQuery(query);
    if (request.getParameter("cust_no").equalsIgnoreCase(resSum.getString("cust_no") && request.getParameter("password").equalsIgnoreCase(resSum.getString("password"))
    %>
    <h2>You are logged in!</h2>
    <%
    else
    %>
    <h2>You better check your username and password!</h2>
    <%
    }catch (ClassNotFoundException cnfe){
    System.err.println(cnfe);
    }catch (SQLException ex ){
    System.err.println( ex);
    }catch (Exception er){
    er.printStackTrace();
    %>
    </body>
    </html>
    I didn't check the code that I wrote. So you may have to fix some part of it. Also this may not be the best solution, but it will help you to understand the process easily.
    The more efficient method is to check whether the result set returned from the database is null or not.... I hope you got the idea... Good luck!
    Rajesh

  • Please help with jsp and database!!

    Hello,
    i first created a jsp page and printed out the parameters of a user's username when they logged in. example, "Welcome user" and it worked fine...
    i inserted a database into my site that validates the username and password, and ever since i did that in dreamweaver, when a user logs in sucessfully, it returns the jsp page like its supposed to, only that it says "Welcome null" instead of "Welcome John." pretty strange, huh!? can anyone please help? thanks!
    here is the important part of the code to Login.jsp, and LoginSuccess.jsp: <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
    <%@ include file="Connections/Login.jsp" %>
    <%
    // *** Validate request to log in to this site.
    String MM_LoginAction = request.getRequestURI();
    if (request.getQueryString() != null && request.getQueryString().length() > 0) MM_LoginAction += "?" + request.getQueryString();
    String MM_valUsername=request.getParameter("Username");
    if (MM_valUsername != null) {
      String MM_fldUserAuthorization="";
      String MM_redirectLoginSuccess="LoginSuccess.jsp";
      String MM_redirectLoginFailed="LoginFailure.jsp";
      String MM_redirectLogin=MM_redirectLoginFailed;
      Driver MM_driverUser = (Driver)Class.forName(MM_Login_DRIVER).newInstance();
      Connection MM_connUser = DriverManager.getConnection(MM_Login_STRING,MM_Login_USERNAME,MM_Login_PASSWORD);
      String MM_pSQL = "SELECT UserName, Password";
      if (!MM_fldUserAuthorization.equals("")) MM_pSQL += "," + MM_fldUserAuthorization;
      MM_pSQL += " FROM MemberInformation WHERE UserName=\'" + MM_valUsername.replace('\'', ' ') + "\' AND Password=\'" + request.getParameter("Password").toString().replace('\'', ' ') + "\'";
      PreparedStatement MM_statementUser = MM_connUser.prepareStatement(MM_pSQL);
      ResultSet MM_rsUser = MM_statementUser.executeQuery();
      boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
      if (MM_rsUser_isNotEmpty) {
        // username and password match - this is a valid user
        session.putValue("MM_Username", MM_valUsername);
        if (!MM_fldUserAuthorization.equals("")) {
          session.putValue("MM_UserAuthorization", MM_rsUser.getString(MM_fldUserAuthorization).trim());
        } else {
          session.putValue("MM_UserAuthorization", "");
        if ((request.getParameter("accessdenied") != null) && false) {
          MM_redirectLoginSuccess = request.getParameter("accessdenied");
        MM_redirectLogin=MM_redirectLoginSuccess;
      MM_rsUser.close();
      MM_connUser.close();
      response.sendRedirect(response.encodeRedirectURL(MM_redirectLogin));
      return;
    %>
          <form action="<%=MM_LoginAction%>" method="get" name="Login" id="Login">
            <table width="55%" border="0">
              <tr>
                <td width="41%">Username </td>
                <td width="59%"><input name="Username" type="text" id="Username" value="" size="25" maxlength="10"></td>
              </tr>
              <tr>
                <td>Password </td>
                <td><input name="Password" type="password" id="Password" value="" size="25" maxlength="10"></td>
              </tr>
              <tr>
                <td> </td>
                <td><input type="submit" name="Submit" value="Submit"></td>
              </tr>
            </table>
          </form>And LoginSuccess.jsp where i want it to print out the "Welcome username
             <%String Name=request.getParameter("Username");
         out.println ("Welcome ");
         out.println (Name); %>

    <%@ page contentType="text/html; charset=iso-8859-1"
    language="java" import="java.sql.*" %>
    <%@ include file="Connections/Login.jsp" %>
    <%
    // *** Validate request to log in to this site.
    String MM_LoginAction = request.getRequestURI();
    if (request.getQueryString() != null &&
    request.getQueryString().length() > 0) MM_LoginAction
    += "?" + request.getQueryString();
    String
    MM_valUsername=request.getParameter("Username");
    if (MM_valUsername != null) {
    String MM_fldUserAuthorization="";
    String MM_redirectLoginSuccess="LoginSuccess.jsp";
    String MM_redirectLoginFailed="LoginFailure.jsp";
    String MM_redirectLogin=MM_redirectLoginFailed;
    Driver MM_driverUser =
    =
    (Driver)Class.forName(MM_Login_DRIVER).newInstance();
    Connection MM_connUser =
    =
    DriverManager.getConnection(MM_Login_STRING,MM_Login_US
    RNAME,MM_Login_PASSWORD);
    String MM_pSQL = "SELECT UserName, Password";
    if (!MM_fldUserAuthorization.equals("")) MM_pSQL +=
    = "," + MM_fldUserAuthorization;
    MM_pSQL += " FROM MemberInformation WHERE
    E UserName=\'" + MM_valUsername.replace('\'', ' ') +
    "\' AND Password=\'" +
    request.getParameter("Password").toString().replace('\'
    , ' ') + "\'";
    PreparedStatement MM_statementUser =
    = MM_connUser.prepareStatement(MM_pSQL);
    ResultSet MM_rsUser =
    = MM_statementUser.executeQuery();
    boolean MM_rsUser_isNotEmpty = MM_rsUser.next();
    if (MM_rsUser_isNotEmpty) {
    // username and password match - this is a valid
    lid user
    session.putValue("MM_Username", MM_valUsername);
    if (!MM_fldUserAuthorization.equals("")) {
    session.putValue("MM_UserAuthorization",
    ion",
    MM_rsUser.getString(MM_fldUserAuthorization).trim());
    } else {
    session.putValue("MM_UserAuthorization", "");
    if ((request.getParameter("accessdenied") != null)
    ll) && false) {
    MM_redirectLoginSuccess =
    ess = request.getParameter("accessdenied");
    MM_redirectLogin=MM_redirectLoginSuccess;
    MM_rsUser.close();
    MM_connUser.close();
    response.sendRedirect(response.encodeRedirectURL(MM_re
    irectLogin));
    return;
    %>
    <form action="<%=MM_LoginAction%>" method="get"
    "get" name="Login" id="Login">
    <table width="55%" border="0">
    <tr>
    <td width="41%">Username </td>
    <td width="59%"><input name="Username"
    ="Username" type="text" id="Username" value=""
    size="25" maxlength="10"></td>
    </tr>
    <tr>
    <td>Password </td>
    <td><input name="Password" type="password"
    ="password" id="Password" value="" size="25"
    maxlength="10"></td>
    </tr>
    <tr>
    <td>�</td>
    <td><input type="submit" name="Submit"
    me="Submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    And LoginSuccess.jsp where i want it to print out the
    "Welcome username
             <%String Name=request.getParameter("Username");
         out.println ("Welcome ");
         out.println (Name); %>When the page is rediredted u r not passing the user name in the query string,so it is not availble in the query string for LoginSuccess page
    Since u have added user in session user this
    <%String Name=(String)session.getValue("MM_Username") ;%>
    <%     out.println ("Welcome ");
    <%      out.println (Name); %>

  • Help with a simple login servlet

    I appreciate any help and assistance you all can give. I'm in an Intro to Java class on Georgia State and have an issue with this servlet I'm building. We're developing a login system where we have an http form pass a studentid and pin number to a servlet, then the servlet will match those inputs against the result set from an access database query using sql. I keep getting an error that will be posted below and I can't see any reason why I'd be getting it. Again any help would be appreciated. Here's the info:
    import java.io.*;
    import java.util.*;
    import java.sql.*; // for JDBC
    import javax.servlet.*; // for Servlet
    import javax.servlet.http.*; // for HttpServlet
    public class StudentLogin extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException{
              //get parameters
                        String aStudentId = (String) request.getParameter("studentid");
              String aPin = (String) request.getParameter("pin");
              //define the data source
                        String url = "jdbc:odbc:CIS3270Project";
                        Connection con = null;
                        Statement stmt;
                        String query;
              ResultSet rs = null;
                        //exception handling
                        try {
                        //load the driver -throws ClassNotFoundException
                        Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
                        catch (ClassNotFoundException cnfe) {
                        System.err.println (cnfe);
         try {
                        con = DriverManager.getConnection (url, "my-user", "my-passwd");
                        // create sql statement
                        stmt = con.createStatement ();
                        query = "SELECT * FROM STUDENT WHERE StudentID='" + aStudentId + "'";
                        // run the query
                        rs = stmt.executeQuery (query);
                        //get data from result set
                             rs.next();
                             String studentId = rs.getString("StudentID");
                             String pin = rs.getString("PIN");
                             System.out.println(studentId);
                             System.out.println(pin);
                   catch (SQLException ex) {
                        ex.printStackTrace();
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
              //compare form data to result set
    if(aPin.equals(pin)){
                   System.out.println("Login Successful");
              else{
                   System.out.println("Login Failed");
    The error is as follows:
    StudentLogin.java:58: cannot resolve symbol
    symbol : variable pin
    location: class StudentLogin
    if(aPin.equals(pin)){
    ^
    1 error
    I've declared pin and there should be no issue with it using it as an argument in this string comparison. Thanks for any light you can shed on this.
    -Matt

    Alright, I've broken up the code and made it more modular. Here's my code for my Authenticator class followed by the code in the servlet.
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class Authenticator{
         //define the data source
         Connection con = null;
         Statement stmt;
         String query;
    ResultSet rs = null;
         public void loadDb(){
              try {
                   //load the driver -throws ClassNotFoundException
                   Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
              catch (ClassNotFoundException cnfe) {
                   System.err.println (cnfe);
              try {
                   con = DriverManager.getConnection ("jdbc:odbc:CIS3270Project", "my-user", "my-passwd");
              catch (SQLException ex) {
                   ex.printStackTrace();
         public void queryDb(String aStudentId){
              try {
                   // create sql statement
                   stmt = con.createStatement ();
                   query = "SELECT * FROM STUDENT WHERE StudentID='" + aStudentId + "'";
                   // run the query
                   rs = stmt.executeQuery (query);
              catch (SQLException xe) {
                   xe.printStackTrace();
              try {
                   //get data from result set
                   rs.next();
                   String studentId = rs.getString("StudentId");
                   String pin = rs.getString("PIN");
              catch (SQLException x) {
                   x.printStackTrace();
         public void isValid(String aPin){
              if(pin.equals(aPin)){
                   System.out.println("Login Successful");
              else{
                   System.out.println("Login Failed");
    Here's the servlet:
    import java.io.*;
    import java.util.*;
    import java.sql.*; // for JDBC
    import javax.servlet.*; // for Servlet
    import javax.servlet.http.*; // for HttpServlet
    public class StudentLogin extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException{
    //get parameters
              String aStudentId = (String) request.getParameter("studentid");
    String aPin = (String) request.getParameter("pin");
         Authenticator a = new Authenticator();
         a.loadDb();
         a.queryDb(aStudentId);
         a.isValid(aPin);
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    //bunch of HTML output shit goes here
    I keep getting an error of cannot resolve symbol in the isValid method. It can't resolve the variable 'pin' from the database query. Does try limit the scope of that variable to only inside that try statement? Thanks for any help you guys can give.

Maybe you are looking for

  • Video Card and PSU upgrade for HP pavilion p6310y?

    Hello, I am a mild gamer and I would like to upgrade my video card so I could play games like minecraft and maplestory without my frame rate dropping every 5-10 min.  When this happens it sounds like the fan in my computer is working really hard and

  • Using WDS and Closed Network

    I need to close an office network that I converted to wireless using apple airport's extreme base station and One relay express and a remote express. I already have it setup sucessfully broadcasting the SSID, but the owner doesnt want anybody seeing

  • External swf in wrong place

    I have finally figured out how to call an external swf file (shouldn't have been as hard as I made it) Nonetheless, when I preview is, besides getting a bunch of errors about sandboxes, the external swf file is not anywhere close to where I placed th

  • Seeking Spry Gallery mouseovered thumbnail identifier/ID

    Hi! I would like to ask my earlier question about the Dynamic Image Preview extension in a different way. I think my point was not clear. Operating in a Spry gallery of thumbnails with my images in 'images/' directory, what is the identifier that wil

  • Add .exe  to my downloads! I thought this was a Mac hmmm...!

    I am downloading some various files(pdf.doc.rtf) using safari 2.0. In OS When I click on a link to begin the download I recieve a message saying. "...." is an application. Are you sure you want to download the application "...".doc.exe If i click dow