Solved

basic servlet container prototype..

Posted on 2007-03-18
8
334 Views
Last Modified: 2013-11-24
Hi,
Can someone give me a 101 on building a basic servlet container that could deliver static web pages or run servlets. I am looking for some pointers that I can follow while writing program for a servlet container.
0
Comment
Question by:bjuneja_2000
  • 4
8 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 18750345
Probably try looking at the source code of the existing open source servlet containers like Tomcat: http://tomcat.apache.org
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18751545
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 500 total points
ID: 18751569
For static web pages, it is fairly simple. You need to create a TCP listener which receives the requests from users and delivers the pages after reading from a directory.

Create server socket - http://www.exampledepot.com/egs/java.net/CreateServerSocket.html

Handle the request in another thread - http://www.exampledepot.com/egs/java.lang/BasicThread.html?l=rel

Reading from a file -
http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html?l=rel

Sending contents back to the client socket - http://www.exampledepot.com/egs/java.net/WriteTextToSocket.html
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:bjuneja_2000
ID: 18763428
Mayankeagle,
I was able to generate static web pages based on your idea.
Any ideas about how to run servlets ?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18768860
You need a servlet container for that - look at the source code of one of the open source containers.
0
 
LVL 3

Expert Comment

by:amodmulay
ID: 18798622
hey buddy download any of the ide's like eclipse or netbeans..ou will get good examples in that.......if u download you will also get a bundled tomcat with it...so you can figure out how things work...i think as a beginer you should find it out urself
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question