Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP & Tomcat problem  RSS feed

 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I am trying to run a JSP with tomcat 3.2.3 Anyone give me a idea how to call a java program or java bean from JSP? Code is greatly appreciated.
Thiru.
 
ernest fakudze
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be wrong but I am faily confident in it because I for one went through the same problem.
In order to work with Java classes in your jsps you first need to edit the server.xml file in your tomcat/conf dir. You probably have noticed that all the examples which come with Tomcat are in the 'examples' directory. What you need to do for your own project is to create a folder for it in the ROOT directory e.g. MySite.
You then have to register this directory (I think we can now safely call it a virtual context) in your server.xml file. Go near the lines...
<Context path="/examples" docBase="webapps/examples" crossContext="false" debug="0" reloadable="true" />
.. and then try and enter 'MySite' in the context path too.
Then you have to create this path in 'MySite' dir
/WEB-INF/CLASSES/
Compile your java classes and put them in the classes dir. Then at the top of your jsp you import a class by
<%@page import ClassName %> (use the page import directive properly because i forgot how to use it)No extension, just the class name only
It should work. I think you put your beans in classes dir too and access them using the properties and so on.
Hey pal, just buy a book and read about this stuff. It's too long for me to explain here but I hope this helps. i'm a newbie too but I'm well on my way!!
Somebody please verify that this is sort of correct.


[This message has been edited by ernest fakudze (edited August 30, 2001).]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!