Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Webapps Folder ?

843836Nov 6 2003 — edited Nov 8 2003
Hello,
i have made a small website; All its class files are in folder
c:\tomcat\webapps\examples\web-inf\classes\mysite\
and all of the jsp pages are in
c:\tomcat\webapps\examples\jsp\mysite\

but, somebody told me there is some procedure to be followed like ...
PROCEDURE
---------
make a folder named "mysite" in "webapps" and then make a folder
"web-inf" and then folder named as "classes" and keep class files there.... Then set class path.
---------------------------
i am using tomcat 4.1.27
Now my question is,
Please tell me these things,what to do?,where to keep class files and jsp pages, and how to change classpath.
And also please tell me if i have to edit some other files like web.xml etc...

Thanks in Advance ....
you can also contact me at sohaiil@hotmail.com

Comments

796254
You shouldn't post your e-mail address. Off-forum communication is frowned upon, and spammers mine lists like these for addresses.

You should learn how to create a WAR file for each app. The Tomcat docs have all that you need to know. Go root around for a while. - MOD
800382
Normally, the structure is like this:

webapps/
webapps/myapp/
webapps/myapp/images/ (or other special content folders)
webapps/myapp/WEB-INF/ (should be all caps, I think)
webapps/myapp/WEB-INF/classes/
webapps/myapp/WEB-INF/lib/
webapps/myapp/WEB-INF/src/

In the src directory, I put the web app class file sources in their package structure. I have a build script that compiles them to the classes director. In the classes directory goes your compiled class files in their package structure. I'm assuming you now about packages and directories (if not, you should start with something other then JSP).
In the lib directory goes and jar files for other library packages.
In the WEB-INF directory itself is the web.xml and any tag library definition files, etc.
I usually just put my JSP pages into the myapp directory itself, but some people will put them in a jsp subdirectory there or something. I don't find that useful, personally.

As for WAR files, I don't use them during development, only when needing to deploy the app. It seems to me a waste of time to create it and let it unpack to test.
843836
Noramlly .............
----------------------
You hav'nt told me ,How to set claspath ,,,
and then how to access a page that's in
webapps/myapp/index.jsp
800382
you don't need to do anything to the class path if you are setting it up that way. everything in the lib and classes directory will be loaded automatically.

the url to access would be http://server/myapp/index.jsp
843836
i have my application in
c:\tomcat\webapps\myapps\WEB-INF\src\voting\Webvoting.java
and
c:\tomcat\webapps\myapps\WEB-INF\classes\voting\Webvoting.class
And i have speciied this package in .java class as

package myapp.voting;

but i am getting an error .........

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 0 in the jsp file: /Result2.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\tomcat\work\Standalone\localhost\myapps\Result2_jsp.java:47: cannot resolve symbol
symbol : class WebVoting
location: package voting
myapps.voting.WebVoting voteBean = null;
^

-------------------------------------------------------------

800382
The class is not in the package myapp.voting, it's in the package voting.

package voting;
843836
i have to keep .class file in classes directory or it will be automatically created by the server while reading .java file in src directory ?
843836
tomcat_home/wepapps/index.jsp (This Welcome page)
/login.jsp (if you want)
/module1/some jsp files(assume that as your project module)
/module2
/...
/module n
/images (in this folder your app images)
/html (in this folder your app html files)
/style (in this folder your app style sheets)
/javascript (in this folder your app javascript files)

/MEB-INT (folder)
/web.xml (must - This your own app deployement config file)
/*.xml (if you have any other xml files)
/*.TLD (if you have any other TLD files)
WEB-INF/classes(classes files , properties if you have)
/lib (jar files (your own app jars))

796254
>
As for WAR files, I don't use them during development,
only when needing to deploy the app. It seems to me a
waste of time to create it and let it unpack to test.
I couldn't disagree more.

JMO, but I'd say that first we make our habits, then our habits make us. I'd get in the habit of always deploying with WAR files.

Why should there be any difference between devl, test, and prod? If you have an automated, reusable build process (you DO know about Ant, right?) you should use it regardless of where your code is deployed.

Ant can compile all the code, run a suite of JUnit tests, create the JARs and WARs, and install or remove them automatically from Tomcat. It's become the standard build tool. Why not use it?

If I was a Tomcat admin, I wouldn't let anybody deploy anything to my server that wasn't in a WAR. I don't want to have to worry about cleaning up a big mess when folks slap stuff into the root directory.

JMO, of course. - MOD
1 - 9
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 6 2003
Added on Nov 6 2003
9 comments
242 views