Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
 Discussion Forums
 HTML, XML, JavaScript...
 Software Reviews
 Editors,Others...
 Top100
 JavaScript Tutorials, ...
 Tutorials
 ASP, CSS, Databases...
 Discussion List
 FAQ, Roundup, Configure ...
 Authoring
 HTML, JavaScript, CSS...
 Design
 Layout, Navigation,...
 Graphics
 Tools, Colors, Images...
 Software
 Browsers, Editors, XML...
 Internet
 Domains, E-Commerce, ...
 WDVL Resources
  Intermdiate, Tutorials,...
 WDVL
 Discussion Lists, Top 100,...
 Technology Jobs


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Top 10 Articles
  1. Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions
  2. JavaScript Tutorial for Programmers
  3. Design
  4. JavaScript Tutorial for Programmers - Objects
  5. JavaScript Tutorial for Programmers - JavaScript Grammar
  6. JavaScript Tutorial for Programmers - Versions of JavaScript
  7. Cascading Style Sheets
  8. JavaScript Tutorial for Programmers - Embedding JavaScript
  9. JavaScript Tutorial for Programmers - Functions
  10. Authoring JavaScript
Domain Name Lookup
Search to find the availability of a domain name. Just enter the complete domain name with extension (.com, .net, .edu)

Appendix A: Compiling & Executing Servlets

April 5, 2000

Compiling the servlets:

A servlet file has a .java extension , so the FirstServlet servlet will be saved in a file FirstServlet.java. Use your favorite 'javac' compiler to compile the sample servlet (and all other servlets). Make sure that the 'servlets.jar' file is in your 'classpath'. So for example, if you installed Java Web Server and the servlets.jar file is in the directory C:\JavaWebServer2.0\lib\servlets.jar then you can compile the servlet with the following command:

	
"javac -classpath 
	C:\JavaWebServer2.0\lib\servlets.jar FirstServlet.java"

The best environment to test - execute servlets is of-course your web server. The Web server should support running servlets.

You can try Apache with Jserv or any other web server with a servlet engine such as Jrun. If you want to try a new web server, download an evaluation copy of Java Web Server, (comes with built in servlet engine). After you install JWS and start the server, it will start by default at port 8080.

One other option is to download the Java Web Server development Kit from Sun and use it for testing.

Once you have your web server and the servlet engine ready you need to set up the default directory from which the servlets will be 'loaded'. For JWS it is '/servlets' under the JWS directory. So put your compiled servlets in this directory.

Also you need to call the servlet invoker. With JWS the /servlet alias starts the invoker. So to access the 'FirstServlet' servlet under 'servlets' directory use the following URL:

	
http://Your Hostname : Port no /servlet/FirstServlet

For e.g.

	
http://localhost:8080/servlet/FirstServlet

So in this article we saw how to build a simple web application using servlets and JSP. One can build on this and make a lot of improvements to the application. First of all we made a lot of assumptions and did not concentrate on the 'best practices' or performance improvements. Secondly we did not use any database such as a table for storing user id, password etc. That helped us not going into the JDBC details as the database calls and connections with reference to servlets need a special treatment. As servlets are multithreaded by default, (Which you can change if you want), one should consider the possible issues with non-thread safe calls. We will try to cover some of these topics in our next article.

Sample Application!
Building Web Applications Using Servlets and JSP
Building Web Applications Using Servlets and JSP Part II


Up to => Home / Authoring / Java / Servlets




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers