It's not a secret anymore!
The moose likes Tomcat and the fly likes Problem: Beans with JSP in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "Problem: Beans with JSP in Tomcat" Watch "Problem: Beans with JSP in Tomcat" New topic
Author

Problem: Beans with JSP in Tomcat

Nick Ueda
Ranch Hand

Joined: Jun 17, 2003
Posts: 40
I am trying to get an example from JSP Weekend Crash Course to work...
D:\jakarta-tomcat\webapps\myWork
is where I have put two files...
FruitOrder.html and confirm.jsp
Previously I have placed and compiled my Fruit.java bean (this file is also list above)in:
D:\jakarta-tomcat\webapps\ROOT\WEB-INF\classes
but this is obviously not being found by Tomcat.
The book told me to do that.
FruitOrder.html calls confirm.jsp which uses the Fruit bean.
I would appreciate anyone's input on how my files should be set up.
I do not know how stuff is being directed to:
D:\jakarta-tomcat\work\DEFAULT\myWork\ is this correct? I assume this is where the JSP goes after being translated into a servlet...
I need to fix this problem quick so I can continue learning JSP...If anymore information is needed to help me solve
this problem...please tell me what and I will be here to give it... Thank you so much for your help...
So when ever I submit information in the html form it gives me this error...
Error: 500
Location: /myWork/confirm.jsp
Internal Servlet Error:
org.apache.jasper.JasperException: Unable to compile Note: sun.tools.javac.Main has been deprecated.
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:50: Class Fruit not found.
Fruit orderedFruit = null;
^
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:53: Class Fruit not found.
orderedFruit= (Fruit)
^
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:58: Class Fruit not found.
orderedFruit = (Fruit) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "Fruit");
^
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:103: Class Fruit not found.
out.print(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getFruitName())));
^
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:110: Class Fruit not found.
out.print(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getColor())));
^
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:117: Class Fruit not found.
out.print(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getPrice())));
^
D:\jakarta-tomcat\work\DEFAULT\myWork\confirm_2.java:124: Class Fruit not found.
out.print(org.apache.jasper.runtime.JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getQuantityInPounds())));
^
7 errors, 1 warning
at org.apache.tomcat.facade.JasperLiaison.javac(Unknown Source)
at org.apache.tomcat.facade.JasperLiaison.processJspFile(Unknown Source)
at org.apache.tomcat.facade.JspInterceptor.requestMap(Unknown Source)
at org.apache.tomcat.core.ContextManager.processRequest(Unknown Source)
at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)
at org.apache.tomcat.core.ContextManager.service(Unknown Source)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Unknown Source)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown Source)
at java.lang.Thread.run(Thread.java:536)
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12267
    
    1
D:\jakarta-tomcat\webapps\myWork
is where I have put two files...
FruitOrder.html and confirm.jsp
Previously I have placed and compiled my Fruit.java bean (this file is also list above)in:
D:\jakarta-tomcat\webapps\ROOT\WEB-INF\classes
but this is obviously not being found by Tomcat.
The book told me to do that.

If you are going to use \webapps\myWork, Tomcat will have to think of \myWork as a web application. That means you will have to use
\webapps\myWork\WEB-INF\
as a base for a web.xml file and the classes directory.
You should get a copy of the servlet API from java.sun.com - it lays out all of the requirements for web applications.
Bill


Java Resources at www.wbrogden.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56173
    
  13

Nick, I also posted an answer to this in the JSP forum. Please don't cross post that same question to multiple forums.
That said, this forum is porbably the most appropriate place for your question. Let's continue any discussion here.
thanks,
bear


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Nick Ueda
Ranch Hand

Joined: Jun 17, 2003
Posts: 40
Originally posted by Bear Bibeault:
Please don't cross post that same question to multiple forums.

Bear,
sorry about that...it won't happen again...
I just got desperate...
Thank You So much for your reply though...
I think it will help alot!
Nick Ueda
Ranch Hand

Joined: Jun 17, 2003
Posts: 40
Originally posted by William Brogden:

That means you will have to use
\webapps\myWork\WEB-INF\
as a base for a web.xml file

So can I use a web.xml file from another directory(the examples directory)as a template or will this throw everything off?
Thanks,
Nick Ueda
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12267
    
    1
I found that careful perusal of web.xml from examples was a big help in understanding how to set up a web.xml, but obviously you need to replace the example names etc. with your own.
The ultimate authority is the servlet API.
Bill
Nick Ueda
Ranch Hand

Joined: Jun 17, 2003
Posts: 40
So Mr. Brogden,
Would you say the Servlet API is the best place to start learning about web servers so I can continue learning JSP?
Thanks,
Nick
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56173
    
  13

Always have a link to the API handy...
And somewhat surprisingly, the Servlet specification itself is very easy to read. I think most people think it'll be filled the technical equivalent of 'legalese' mumbo-jumbo, but it's actually a very informative read.
I highly recommend it for anyone writing web apps.
hth,
bear
[ June 25, 2003: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56173
    
  13

Servlet 2.3 Specification
Nick Ueda
Ranch Hand

Joined: Jun 17, 2003
Posts: 40
Thank you Bear, Mr. Brogden, and all others who helped.
You Are The Best!
It Works Now!
Nick Ueda
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Problem: Beans with JSP in Tomcat
 
Similar Threads
jsp weekend crash course - chapter 11
Tomcat doesn't see Java bean
Problems with Bean in JSP...
need help for JasperException
Java Bean in JSP