Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problem: Beans with JSP in Tomcat

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nick Ueda
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
 
Nick Ueda
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Bear, Mr. Brogden, and all others who helped.
You Are The Best!
It Works Now!
Nick Ueda
 
Do you pee on your compost? Does this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic