• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlets on J2EE

 
aamir abbas
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to use J2EE server to run servlets. Where should I put the servlet class and how should I request the servlet from the browser.
Thanx in Advance
Aamir
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This information is different for every app server out there.

But, for the reference implementation: You need to make a WAR file that contains your servlet as a web component. The WAR file will have a web context root < webroot > and the servlet will have an alias < alias >, and once deployed you can access the servlet like so:

http: //localhost:8000/< webroot >/< alias >?yourparams=here&etc=etc

[This message has been edited by Mike Curwen (edited May 16, 2001).]
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you give an example of that? I've never heard of a war file. Someone told me I needed to do something with an xml file.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WAR means Web Archive file. It is simillar to Jar file. (Java Archive).
We just create a jar file and rename it as .war file. To create a .jar file we use "jar -cf test.jar *.class"
Another simple way is "jar -cf test.war *.class"
Jar's story started with applets to reduce the download time of applets over internet because they are compressed.
Simillarly .war file is for server side web applications. Since a web application comtains many types of files with pre-defined directory structure dictated by Servlet 2.2 API, it is very easy give away our application in ONE SINGLE COMPRESSED FILE (perStore.war) to a deployer to deploy in their servlet containers.
For the deployer also the work is very easy. They just copy petstore.war file to the deployment directory of their servlet engine. No need to unzip(extract) .war file. The servlet spec dictates that all servlet engines should take of extracting the .war file and pull out resources on the fly.

Personally I found this concepy VERY USEFUL because, I developed a servlet/jsp web application in home machine and uploaded to free server at www.webappcabaret.com. My application had nearly 50 files and imagine we make 50 uploades to webappcabaret.... wasete of time ISn't? What I did was whenever I made changes at home machine, just recreated .war file and uploded one single .war file to webappcabaret. Simple and sweet.!
We have to create this .war file with the standard dir structure of web appln. ( all those ...WEB-INF/classes dirs)
Sun's tutorial on Jar is here. (Very good! )
http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/jar.html
regds
maha anna
 
aamir abbas
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx All,
i have done it successfully
Aamir
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aamir,
how did you get it working. I'm still clueless.
Thanks.
 
aamir abbas
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sean,
its very simple, i just deploy my servlet (Hello.class) and during servlet i enter 'test' for context root and 'Hello' for Servlet Alias . . . after successfull deployment i run my servlet as http://localhost:8000/test/Hello
here 'test' is context root and 'Hello' is Alias.
Aamir
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!