Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 517
  • Last Modified:

JSP Error

Hi All,
I am running Tomcat 4.1.27 on Linux. Java is   Version 1.4.1-01
I have a class file DBUsernamePassword in WEB-INF/classes/<packagename>/DBUsernamePassword.class

When I try running the JSP... I get error in JSP's which use the class file....
The is what i get in log file
-------------------------------------------------------------------------------------------------------------------------------
2004-08-05 12:49:59 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: DBUsernamePassword
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.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:2416)
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:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
----- Root Cause -----
javax.servlet.ServletException: DBUsernamePassword
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.process_login_jsp._jspService(process_login_jsp.java:261)
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.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:2416)
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:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
-------------------------------------------------------------------------------------------------------------------------------

Any idea what the error is?
0
chitman
Asked:
chitman
  • 6
  • 4
  • 3
  • +1
1 Solution
 
TimYatesCommented:
can you post the jsp?
0
 
indigostarkCommented:
Yes,
Could you please post your code.
I suggest that you may have not properly imported the class
0
 
TimYatesCommented:
or DBUsernamePassword is throwing an exception you do not catch in the jsp...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
chitmanAuthor Commented:
I am copying part of my jsp file here
---------------------------------------------------------------
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="javax.servlet.*" %>
<jsp:useBean id="uid" class="DBUsernamePassword" scope="application" />
<%@ page import="p1.*"%>

<%
try
{
String u=uid.getUsername();
String p=uid.getPassword();

Connection conn =null;
      Class.forName("oracle.jdbc.driver.OracleDriver");

      conn = DriverManager.getConnection(
                "jdbc:oracle:thin:@x.x.x.x:1521:db",
                u,
                p);

      stmt1 = conn.createStatement();

....
---------------------------------------------------------------
Here is my DBUsernmaePassword file
---------------------------------------------------------------
package p1;

public class DBUsernamePassword {
  public static String getUsername() {
    return "user1";
  }

  public static String getPassword() {
    return "password1";
  }
}
---------------------------------------------------------------
0
 
Mayank SAssociate Director - Product EngineeringCommented:
DBUserNamePassword contains the methods getUsername () and getPassword () as static, so why do you need a bean to access them? You can directly use this:

String u = DBUserNamePassword.getUsername () ;
String p = DBUserNamePassword.getPassword () ;
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> DBUserNamePassword

DBUsernamePassword, with a small 'n' ;-)
0
 
TimYatesCommented:
Swap these two lines over in the jsp:

<jsp:useBean id="uid" class="DBUsernamePassword" scope="application" />
<%@ page import="p1.*"%>

so that you have:

<%@ page import="p1.*"%>
<jsp:useBean id="uid" class="DBUsernamePassword" scope="application" />

You need to import the package BEFORE you call classes inside it ;-)

Tim
0
 
Mayank SAssociate Director - Product EngineeringCommented:
>> Swap these two lines over in the jsp:

You might as well just remove <jsp:useBean....>

You can access the methods using the class-name since they are static.
0
 
TimYatesCommented:
True ;-)
0
 
chitmanAuthor Commented:
Hi...
It did work... but I want to know the differnce between the following code

<%@ page import="p1.*"%>
<%
String u = DBUsernamePassword.getUsername() ;
String p = DBUsernamePassword.getPassword() ;
%>


 and


<jsp:useBean id="uid" class="DBUsernamePassword" scope="application" />

<%
String u=uid.getUsername();
String p=uid.getPassword();
%>
0
 
Mayank SAssociate Director - Product EngineeringCommented:
The second would've been fine if you had the methods defined as:

public String getUsername() {

instead of: >> public static String getUsername() {

(note the difference is the 'static' keyword'). When you define a bean "uid", it is like an object of the class "DBUsernamePassword", and so, you can access the getUsernamePassword () method with it. But if the method is static, you don't need the object and you can access it directly by using the class-name like ClassName.method () ;

0
 
Mayank SAssociate Director - Product EngineeringCommented:
0
 
chitmanAuthor Commented:
THANKS A LOT...
:)
0
 
Mayank SAssociate Director - Product EngineeringCommented:
:-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now