Solved

using int value returned by a javabean

Posted on 2004-04-26
7
292 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

13 Experts available now in Live!

Get 1:1 Help Now