Solved

JSP Error

Posted on 2004-08-05
14
508 Views
Last Modified: 2010-04-01
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
Comment
Question by:chitman
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11724841
can you post the jsp?
0
 
LVL 4

Expert Comment

by:indigostark
ID: 11724888
Yes,
Could you please post your code.
I suggest that you may have not properly imported the class
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11724956
or DBUsernamePassword is throwing an exception you do not catch in the jsp...
0
 

Author Comment

by:chitman
ID: 11732872
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
 
LVL 30

Accepted Solution

by:
mayankeagle earned 50 total points
ID: 11733461
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
 
LVL 30

Expert Comment

by:mayankeagle
ID: 11733462
>> DBUserNamePassword

DBUsernamePassword, with a small 'n' ;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11733774
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 30

Expert Comment

by:mayankeagle
ID: 11733820
>> 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
 
LVL 35

Expert Comment

by:TimYates
ID: 11733829
True ;-)
0
 

Author Comment

by:chitman
ID: 11733840
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
 
LVL 30

Expert Comment

by:mayankeagle
ID: 11733858
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
 
LVL 30

Expert Comment

by:mayankeagle
ID: 11733864
0
 

Author Comment

by:chitman
ID: 11733893
THANKS A LOT...
:)
0
 
LVL 30

Expert Comment

by:mayankeagle
ID: 11733925
:-)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

23 Experts available now in Live!

Get 1:1 Help Now