tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Smith <d...@cornell.edu>
Subject Re: Can't execute servlet project
Date Wed, 27 Aug 2008 11:59:16 GMT
I see .... the jsp is a view and as such wasn't designed to be run on 
it's own.  Try http://localhost/DBTest/ListCustomers in your browser.  
That should hit the servlet which in turn should generate the required 
bean and forward the user to your jsp.

--David


sam wun wrote:
> Hi, thanks for trying to help.
>
> I dont' have a clue on this *bean*.
>
> The entire tutorial doesn't mention about how to setup a bean...
>
>
>
> The tutorial I;ve followed is shown as below:
>
> http://java.sys-con.com/node/152270
>
>
>
>
>
> Thanks
>
> Sam
>
>
>
>   
>> ----- Original Message -----
>> From: David Smith
>> Sent: 26/08/08 11:28 pm
>> To: Tomcat Users List
>> Subject: Re: Can't execute servlet project
>>
>> 1. The 404 error accessing /DbTest/ -- define a welcome file in 
>> DBTest/WEB-INF/web.xml.  Online docs at tomcat.apache.org and the 
>> servlet spec will help with this.
>>
>> 2. It would appear you need to do some more research on what you want to 
>> do.  It looks like you are trying to expose an ArrayList stored in the 
>> request scope, but the jsp can't find it, hence the error.  Where is 
>> this object supposed to come from if you didn't create a bean?
>>
>> --David
>>
>> sam wun wrote:
>>     
>>> HI tere,
>>>
>>> I have completed a servlet project in Eclipse (3.4).
>>> I also made a war.file by seleting the project name (DBTest in this 
>>>       
>> case) 
>>     
>>> and the export command from the Eclipse menu, and export it to the 
>>>       
>> Tomcat 
>>     
>>> 5.5.26 server in linux using manager.
>>>
>>> However when I click on the project name (/DBTest) in the manager 
>>>       
>> webpage, 
>>     
>>> it shown the following error:
>>> =================================
>>> HTTP Status 404 - /DBTest/
>>> type Status report
>>> message /DBTest/
>>>
>>> description The requested resource (/DBTest/) is not available.
>>> Apache Tomcat/5.5.26
>>> =================================
>>>
>>> Here is the jsp file in the tomcat server:
>>> linux:~/tomcat/apache-tomcat-5.5.26/webapps/DBTest # ls
>>> .  ..  META-INF  WEB-INF  customers.jsp
>>> its content is shown as below:
>>> ----------------------------------------
>>> linux:~/tomcat/apache-tomcat-5.5.26/webapps/DBTest # vi customers.jsp
>>> <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
>>>     pageEncoding="ISO-8859-1"%>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>>> <html>
>>> <head>
>>> <meta http-equiv="Content-Type" content="text/html; 
>>>       
>> charset=ISO-8859-1">
>>     
>>> <title>Customers list</title>
>>> </head>
>>> <body>
>>>
>>> <jsp:useBean id="customers" type="java.util.ArrayList<domain.Customer>"

>>> scope="request"/>
>>>
>>> <b>Registered Customers:</b><br>
>>> <table border="1">
>>> <tr>
>>>         <th>ID</th>
>>>         <th>First Name</th>
>>>         <th>Last Name</th>
>>>         <th>Address</th>
>>> <th>Orders</th>
>>> </tr>
>>> <% for(domain.Customer c : customers) { %>
>>> <tr>
>>>         <td><%= c.getId() %></td>
>>>         <td><%= c.getFirstName() %></td>
>>>         <td><%= c.getLastName() %></td>
>>>         <td><%= c.getAddress() %></td>
>>>         <td><a href="/DBTest/ListCustomerOrders?cust_id=<%= 
>>> c.getId() %>">Orders</a></td>
>>> <% } %>
>>>
>>> </body>
>>> </html>
>>> --------------------------------------------
>>>
>>> If I execute a more specific url 
>>> (http://10.1.9.1:8080/DBTest/customers.jsp) from the web browser 
>>>       
>> (firefox),
>>     
>>> it shows different errors:
>>>
>>> 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: Exception in JSP: /customers.jsp:11
>>>
>>> 8: </head>
>>> 9: <body>
>>> 10: 
>>> 11: <jsp:useBean id="customers" 
>>>       
>> type="java.util.ArrayList<domain.Customer>" 
>>     
>>> scope="request"/>
>>> 12: 
>>> 13: <b>Registered Customers:</b><br>
>>> 14: <table border="1">
>>>
>>>
>>> Stacktrace:
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
>>     
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
>>     
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
>>     
>>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> root cause
>>>
>>> javax.servlet.ServletException: bean customers not found within scope
>>>     
>>>
>>>       
>> org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
>>     
>>>     
>>>
>>>       
>> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
>>     
>>>     org.apache.jsp.customers_jsp._jspService(customers_jsp.java:97)
>>>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
>>     
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
>>     
>>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> root cause
>>>
>>> java.lang.InstantiationException: bean customers not found within scope
>>>     org.apache.jsp.customers_jsp._jspService(customers_jsp.java:55)
>>>     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
>>     
>>>     
>>>
>>>       
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
>>     
>>>     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>>>     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>
>>> note The full stack trace of the root cause is available in the Apache 
>>> Tomcat/5.5.26 logs.
>>>
>>>
>>> I haven't create any *bean*, but servlet only.
>>> How to get fix problem?
>>>
>>> Your help is much appreciated.
>>>
>>> Thanks
>>> Sam
>>>
>>>       


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message