jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes JSP/Servlet library for standalone application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP/Servlet library for standalone application?" Watch "JSP/Servlet library for standalone application?" New topic

JSP/Servlet library for standalone application?

Tom Rodrigo

Joined: Dec 07, 2001
Posts: 26
Hi all,
I don't know much about JSP and Servlets but was wondering if a package which is intended for the use with JSP/Servlet also can be used for a java application. Can this be done easily or is it more complicated?
Vikas Aggarwal
Ranch Hand

Joined: Jun 22, 2001
Posts: 140
Mostly you can not because they are HTTP based and require javax.servlet package to work.

Vikas Aggarwal

Founder @
Leads and Deals Limited

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You can embed a servlet engine in a Java application so that it could run servlets and JSP but you would still have to use a browser to see the resulting HTML.
Article on embedded Tomcat
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

... Either that or use an HttpURLConnection!

An IDE is no substitute for an Intelligent Developer.
Ken Robinson
Ranch Hand

Joined: Jul 25, 2002
Posts: 52
Servlets can be thought of a 'plug ins' to a web browser. Bits of logic you write that take a web request, do a bit of work and return a new page (usually via JSP).
It is totally possible to write your logic as a series of Servlets and then have a stand along front end (using an HttpURLConnection as stated) to connect to the web server, get the bit you want and parse the output (HTML or even XML).
The more common approach is to deploy the logic as a series of EJBs. Both the Servlet and Stand Alone App would be clients of the EJB. This allows you to code and deploy the logic only once while making use of it in several locations.
Tom Rodrigo

Joined: Dec 07, 2001
Posts: 26
Hi vikinsa, William, Tim & Ken,
thanks for all of your answers, this is what I needed to know!
I agree. Here's the link: http://aspose.com/file-tools
subject: JSP/Servlet library for standalone application?
It's not a secret anymore!