*
The moose likes Tomcat and the fly likes Tomcat 7 jsp/DAO Problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 7 jsp/DAO Problems" Watch "Tomcat 7 jsp/DAO Problems" New topic
Author

Tomcat 7 jsp/DAO Problems

john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
I am using tomat 7.0.8. I am trying to access basic information in a database using the DAO (direct access object) design pattern. The problem I am having is that the data shows fine when I use a servlet. However, when trying to use a jsp file (which is preferred) I get an error that says the DAO object is not a recognized type. Here are the details:
Working Servlet:

Jsp That does not work

Up to this point I have not been using Ant or any kind of deployment software. I manually created my root folder brain(C:\Tomcat7.0\webapps\brain) and in it are my jsp files. The WEB-INF folder that has the classes folder, in which are all the classes, is also in brain.(C:\Tomcat7.0\webapps\brain\WEB-INF\classes). To ensure clarity here is the main part of the error message that Tomcat spits out:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60748
    
  65

The time to be putting Java code in a JSP is long long past. Doing so is not preferred, in fact, at this stage it's irresponsible.

Keep the Java code in a Servlet, and use JSP only to generate the HTML views using JSTL and EL.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
Agreed. But as you see I will need to pass an Array List from a servlet to a jsp. How do I do that? I know how to pass data from a servlet to a jsp using a session.



I assume this is not the preferred method. Setting a session to pass object data does not seem efficient?
john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
In addition, the code submitted is for coursework. Its just to get an understanding of the process. Having said that, why don't the jsp recognize my dao object?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60748
    
  65

Why would you need to use the session? Attach the scoped variable to the request.
john gere
Greenhorn

Joined: Mar 10, 2011
Posts: 22
Thank you for the help. I have resolved the issue by using a servlet and then passing the data to the jsp.
Servlet Code:

Jsp code:

Once again thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60748
    
  65

A good step in the right direction!

The next step to take is to learn the JSTL and EL and replace all Java code on the JSP!
 
jQuery in Action, 2nd edition
 
subject: Tomcat 7 jsp/DAO Problems
 
Similar Threads
JSP two pages
Folder Creation On Server
Displaying the right details of a resource taken from a JSP results page
please help me with this app - URGENT !
Insert appropriate data against right question