GeeCON Prague 2014*
The moose likes Servlets and the fly likes running a simple servlet (.war needed? ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "running a simple servlet (.war needed? )" Watch "running a simple servlet (.war needed? )" New topic
Author

running a simple servlet (.war needed? )

Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
Hi,

do i need to create a .war file for a simple servlet which is to receive querries, handle them and then return xml data back to the client side application (flex/action script)?

i am not displaying anything, all i want is for the data to be received - serverside, processed, and sent back to the client....to the best of my understanding i wouldnt need a .jsp page for this, right ?

so what -for example- comes into my .war file if i want to implement my servlet ?

best regards

-W
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No, war files are just a format for packaging an entire application into a single file.

Most (as far as I am aware) containers allow you work with a file structure.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
Thanks Ben!

for the scenario i described, is a .jsp page of any use to me ?

-W.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A servlet would be a better choice of tools.
JSPs are best used for formatting and marking up the response to a request.
Wolfgang Obi
Ranch Hand

Joined: Dec 05, 2005
Posts: 134
oh, okay...

and could you maybe explain (or point to a resource which describes -) how to create a .war file ?

cheers

-W
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A war file is nothing more than a jar file (which is nothing more than a zip file) with a particular directory structure.

If you have a copy of Tomcat running on your machine the following exercise can be done in under 5 minutes.

With Tomcat running:
  • Download SimpleServlet.war from our CodeBarn to your tomcat/webapps directory.
  • Let Tomcat deploy this application (you will see a new directory named "SimplServlet" created in the webapps directory).
  • Test this app by pointing your browser to http://localhost:8080/SimpleServlet
  • Open a command window and CD to tomcat/webapps/SimpleServlet
  • At the command line type: jar cvf c:\temp\NewSimpleServlet.war *

  • This assumes that you already have a c:\temp directoryYou will now have a war file named NewSimpleServlet in your c:\temp directory
    [ June 23, 2008: Message edited by: Ben Souther ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: running a simple servlet (.war needed? )