|
||
|
|||
|
Hello Friends.
I am working on Java Web Server. Static contents are being returned by server. But I have to process Servlets. How can I do it? I can get Servlet position from Web.xml and all other info of Servlets. But how can I process it? Web server first call intit() method of servlet, then service(), then destroy(). I am unable to understand, how it can b done? Please guide me.
|
|
|||
|
It's not completely cleare for me what you are tryin to say. Do you want to map URL's to certain controllers? Or do you want to implement your own servlet?
In the first case: Use the web.xml to define the servlet and map it to an URL pattern like *.htm. When this matches, the application server will use the [yourservletname]-servlet.xml to match a certain URL pattern to a controller. In the second case: use the first case to understand the construct. Then use google to find out how a servlet works. I'm not quite sure because I always use the default one that comes with Spring. |
|
||||
|
I think he is actually writing a web server/servlet container.
You could try using reflection to create the servlet etc. Just look in the web.xml for the servlet definition and grab the class. Use reflection to create an instance of that object -> Trail: The Reflection API (The Java™ Tutorials) // Json |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java Chat Server Help. | illucidryan | Java Networking | 10 | 08-05-2009 03:49 PM |
| Java Server Chat, Help Needed PLEASE!! - NullPointerException | Valtros | Exceptions | 1 | 08-05-2009 10:06 AM |