Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JSP Error

Posted on 2004-08-05
14
Medium Priority
?
515 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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:
Mayank S earned 200 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:Mayank S
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
 
LVL 30

Expert Comment

by:Mayank S
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:Mayank S
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:Mayank S
ID: 11733864
0
 

Author Comment

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

Expert Comment

by:Mayank S
ID: 11733925
:-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Check out what's been happening in the Experts Exchange community.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

730 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