• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JSP Newbie needs help getting a clue!

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got PHP, Perl, MySQL, ASP, etc....

I want Java JSP and all that jazz

I have successfully installed Tomcat and want to get started on some tutorials, but I get lost with servlets and beans.

I can compile my beans and servlets and stuff, but WHERE DO YOU PUT THEM!!

every time I try to reference anything, the server can't find them....

All these tutorials tell you how to write code - which comes easy for me - Its the setup and configureation I am lost with.

Could someone help me with some advise on how to configure tomecat so I know where to put beans and servlets

(also why servlets vs jsp vs beans )

I appreciate all your help..

Thanks James
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry... I know forgive me for my spelling...
I'm a programmer not an english scholar - or should that be skawlor
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Tomcat documentation includes info on how to set up a web app. The documentaion web app is already configured when you load Tomcat.

Quickie overview:

1) Create a folder to serve as the 'document base'. It can be anywhere on your system. If you want Tomcat to pick it up automatically put it in $CATALINA_HOME/webapps.

2) In this folder create a folder named WEB-INF.

3) In WEB-INF create folders classes and lib. Your class hierarchy (be sure that all classes are in packages other than the default) goes in classes. Any jar files your app needs go in lib.

4) Create your web.xml file in WEB-INF.

5) Create your JSPs and such. They can go in the root of your folder structure, or in any folder hierarchy therein. If you want to hide them from the world (so that they can only be accessed via their servlet controllers -- a good pattern to follow), place them in a folder hiearchy under WEB-INF.

Refer to the docs for any further details.
[ May 03, 2005: Message edited by: Bear Bibeault ]
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for your reply.

Please forgive me I get lost sometimes. I have tried to read through the documentation and it is fuzzy at best. Maybe I don't know what I am doing... I guess that is why I am here...

I have done what you have suggested. I will need to learn more about the package setup etc... for the classes folder.

I cannot see my new folder

I created a folder called "arg" in /var/tomcat4/webaps/
I created the WEB-INF folder inside ./arg
I copied and pasted the web.xml from /var/tomcat4/ROOT/WEB-INF/web.xml
- it was basic enough for what I think I am doing

when I browse to the location http://server:8180/arg I get an error saying:

"
type Status report
message /arg/
description The requested resource (/arg/) is not available.
"

Is there a missing step?

man I tell ya I don't have a problem with the coding... its all the symantecs of setting it up...

I really do appreciate your help.

Thanks, James
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anything there to serve up? Did you place an index.html or index.jsp file there?

P.S. Don't feel frustrated. There is a lot to learn about setting up your first web app. Especially if you want to do it correctly. Have you found the Tomcat docs?
[ May 03, 2005: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have some simple pre-configured apps that you might want to take a look at.
They're not a substitute for reading and going through tutorials but sometime it helps to have a working example to reference.

http://simple.souther.us
Follow the directions on the site for deploying (should be about 5 to 7 mouse clicks if you have Tomcat up and running already).

Look at SimpleServlet and SimpleJSP first.
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much

I will treasure these links, but I am still having problems.

1. I did put content into my "arg" folder index.html existed
2. After reading the docs... I saw that I actually needed to rstart Tomcat Imagine that! took me a while to find it... but... I found it

3. I have tried the SimpleServlet and SimpleJSP examples. All I get is a 404 error message. I have copied the .war files down. Restarted. The .war files unpacked, but when I browse to them http://webserver:8180/SimpleServlet and http://webserver:8180/SimpleJSP/index.html .... no dice
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you configure Tomcat to run on 8180?
By default it runs on 8080.

Can you hit the Tomcat welcome page?
http://localhost:8080
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok...

I think I found a problem with SimpleServlet...

I checked the logs - yes logs are our friends - I am getting an error for SimpleServlet and SimpleJSP saying:

Parse error in application web.xml
org.xml.sax.SAXParseException: Element type "web-app" must be declared.

....

I got it to work...

Insight would be appreciated

...


the web.xml for both SimpleJSP and Simple Servant had a <web-app> block that was defined as:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

when this was present I got the errors

I changed it to
<web-app>

and it worked...

do you know what the difference is (other than <web-app> is simpler?)

Thanks again for all of your help

James
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which version of Tomcat are you running?
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running 4.0.3-1

Also... I installed using an RPM which set up a default port of 8180. Whenever I try to use 8080 it times out...

It doesn't matter much to me... It is my developent server at home. I am just trying to get to a point where I can start developing cool stuff.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did test those examples on 4.1.
Thanks for letting me know about the problem.
I'll put a note on my site letting people know there is an issue.

Out of curiosity, why are you using such an out of date version?
A lot of the stuff you'll find in tutorials these days (and a lot of things discussed in this forum) such as EL will not work in 4.0.
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the final version of a basic web.xml I got to work. I copied it from the /var/tomcat4/webaps/ROOT/WEB-INF/web.xml


<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
</web-app>


thanks,
your samples are a great start to what I want to do

James
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh I picked 4 because that is just what I found...

I found a tutorial for tomcat and I get so lost as to what to get I just followed the instructions and it used RPM's

RPM's are my friend
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason your web-app declaration failed was because that is a Servlet 2.4 declaration and Tomcat 4 supports 2.3. I suggest you upgeade to Tomcat 5 before proceeding any further.
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great...

Do you know of any good tutorials to follow to reinstall for 5
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really appreciate all the help you all have given.

I actually feel that I have a grasp on this stuff now. I feel that if someone gave me a simple assignment, I could realy do it.

thanks so much

James
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you'll find the non-rpm install to be trivial.

Download the tar.gz file.
Unpack it (tar -zxvf jakarta-tomcat...)
Set your JAVA_HOME environment variable (export JAVA_HOME=/usr/local/jdk1...)
CD to the {where ever you put tomcat}/bin directory.
Start Tomcat (./startup.sh)

Note: 5.5x requires Java5 unless you also get the "compat.tar.gz" file and unpack it from the same directory that unpacked tomcat into.
 
icredes
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok... we have 5.5.9 in the house

it is now time to rock and/or roll
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Congrats and welcome to j2ee, Javaranch
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
man! wish i knew about java ranch when i started out on servlets etc!!!

thanks a lot anyway to all the guys here!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic