Solved

using int value returned by a javabean

Posted on 2004-04-26
7
294 Views
Last Modified: 2010-04-01
well, i'm new to jsp & javabean development and been having some what i consider as should be simple problems.

i''ve created a javabean that checks and returns an integer value of what the user did.  it checks for user's id & password and depending on the user's correct info level, i'm returning a number.  so 0 = no match, 1 = user id match, 2 = user id match but password wrong, 3 = all match.

in my jsp, i'm just trying to use the value that's returned.

well, i originally tested the bean just passing back true or false.  so if the user's id matched, return true.  that worked fine.  now i''ve changed everything to use these int and it just doesn't seem to do anything but bomb.  i tried to use Integer.parseInt but didn't do anything.

can you help me out?

as i'm sure it's usually the case here, i really need this working asap.

some code:

in javabean:
        public int existsUser (String strEmail, String strPassword) {
           
            String url = "jdbcdriver";
            Connection con;
            Statement stmt;
            String query = "select UserID, Password from Authorization where Email = '" + strEmail + "'";
                // 0= user does not exist, 1 = user exists but did not match password,
                //2 = user exists, but password wrong, 3 = all matched & good
                int intHaveRS = 0;
                String strUID = "";
                String strPass = "";
      
            try {
                  Class.forName("com.mysql.jdbc.Driver");
      
            } catch(java.lang.ClassNotFoundException e) {
                  System.err.print("ClassNotFoundException: ");
                  System.err.println(e.getMessage());
                  return 0;
            }

            try {
                  con = DriverManager.getConnection(url, "iars_bears", "iars_bears");
      
                  stmt = con.createStatement();
      
                  ResultSet rs = stmt.executeQuery(query);
      
                  if (rs.next()) {
                        strUID = rs.getString("UserID");
                                strPass = rs.getString("Password");
                                intHaveRS = 1;
                                if (strPassword.equals(strPass)) {
                                    intHaveRS = 3;
                                } else {
                                    intHaveRS = 2;
                                }
                  } else {
                        setUID(null);
                                intHaveRS = 0;
                  }
      
                  stmt.close();
                  con.close();
      
            } catch(SQLException ex) {
                  System.err.println("SQLException: " + ex.getMessage());
                  return 0;
            }

            return intHaveRS;
           
        }

and jsp:
<%@page import="java.lang.*, java.io.*" %>
<jsp:useBean id="Authorization" class="msk.Authorization" />
<%
int iUExist=0;

if (request.getParameter("btnSubmit") != null)  {
    iUExist = Authorization.existsUser((request.getParameter("txtEmail")),(request.getParameter("txtPassword")));
    if (iUExist > 0) {
        out.print("this user exists! " + iUExist);
    } else {
        out.print("this user DOES NOT exists!");
    }
}

%>

<p>Welcome!</p>
<form name="frmAdmLogin" method="post" action="">
  <p>user email
    <input type="text" name="txtEmail">
  </p>
  <p>user password
    <input type="text" name="txtPassword">
  </p>
  <p>
    <input type="submit" name="btnSubmit" value="Submit">
    <input type="reset" name="btnCancel" value="Cancel">
  </p>
</form>
</body>
0
Comment
Question by:mskim100
  • 4
  • 3
7 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 10923042
what's the error message?
0
 

Author Comment

by:mskim100
ID: 10923251
this is what i get

mskim100
=========================

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: msk.Authorization.existsUser(Ljava/lang/String;Ljava/lang/String;)I
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      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:256)
      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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
      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.StandardContext.invoke(StandardContext.java:2417)
      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:171)
      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:193)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
      at java.lang.Thread.run(Thread.java:534)


root cause

javax.servlet.ServletException: msk.Authorization.existsUser(Ljava/lang/String;Ljava/lang/String;)I
      at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
      at org.apache.jsp.admLogin_jsp._jspService(admLogin_jsp.java:108)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      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:256)
      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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
      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.StandardContext.invoke(StandardContext.java:2417)
      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:171)
      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:193)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:589)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:666)
      at java.lang.Thread.run(Thread.java:534)
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 10923301
to avoid the obvious, you've re-compiled your bean and restarted your server right?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:mskim100
ID: 10923328
i've recompiled my bean but it's a remote server and i can't restart.  i did reload my class tho.
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 500 total points
ID: 10923385
you have to restart... it's probably using your old bean which is why when you try to assign the int value it bombs... existsUser is probably still returning a boolean.
0
 

Author Comment

by:mskim100
ID: 10923414
so as far as you can see, i should be able to use my int that's returned from my bean?  well, i'll have to ask someone to restart then.  i'll let you know what happens when i get it restarted.

mskim100
0
 

Author Comment

by:mskim100
ID: 10923680
restart worked!

thanks!

mskim100
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
form submissions on a web page 2 143
JSP Popup page 2 108
library class in java 1 90
hashcode is calculated on the basis of value object 2 104
In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
There is no doubt that cloud is gaining importance. Many of you must have read about this technology and its growing importance. More and more organisations are embracing this technology not forgetting start-ups. The process begins by dipping …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now