Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between registered and unregistered servlets

 
Sridhar Garimella
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am sreedhar.I am working as a java programmer.I have one dought about servlets.My question is what is the difference between a servlet which is registered in a java webserver(some name) and a servlet which is not registered.More specifically is there any advantages when i registered my servlet in a webserver?
if they are why?
Thanks in advance sreedhar garimella
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are several differences common to most or all web servers and servlet engines, and some others which may be more specific.
By "unregistered", I assume you mean a servlet placed in a directory scanned by the servlet engine and invoked by its class name. By "registered" I assume you mean a servlet placed anywhere in the classpath, but you have informed the servlet engine where it is, and optionally told the servlet engine more
information.
The first restriction on unregistered servlets is the name. An unregistered servlet can only respond to a URL of the form
/servlets/classname. This means that you can't use a more application-specific name for a more general servlet, and you can't have more than one name for the same servlet.
For example, if you have a servlet GenericListServlet, it can only appear as /servlets/GenericListServlet, but if you are using it to hold a list of staff details for a company, it might make more sense for your customers to know it as /servlets/stafflist.
The second restriction is where the servlet is "mapped". Many servlet engines allow registered servlets to be mapped on one or more URLs or URL-patterns. For example you might want to put the staff list servlet above on a URL like /company/people/stafflist or even /company/people/stafflist.html to hide the fact that it is dynamically generated.
Mapping a servlet on a URL-pattern can be especially powerful. Consider mapping the stafflist servlet to any URL ending in '/people' like /company/accounts-dept/people or /company/sales-dept/people.
The third restriction is on initialization parameters. Registering a servlet allows you to enter initialization parameters which can affect how the servlet operates. Imagine you want to use the same GenericListServlet for both the staff list and product list for a company. You could map the same servlet to /products and /staff, then tell the one mapped to /products to look in the database "prod-info" for its details, and the one mapped to /staff to look in the "staff-details" database.
Specific servlet engines may give extra advantages, but the bottom line is that registered servlets can be a <b>lot</b> more powerful and flexible. Note, however, that the new "web application" concept introduced in version 2.2 of the servlet spec can bring some of these advantages to unregistered servlets, but not many servlet engines, and even fewer commercial web hosts support this version yet.
 
Sridhar Garimella
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frank,
You provide good information about the diffrences.For that i am thankful to you.I have one more dought on second difference you mentioned i.e., mapping.Through servlet aliasing we can also map the servlet with other name(i think if not correct my mistake).Then what is the difference between this and servlet registration with respect to mapping.Further my email is
sreedhar_gari@hotmail.com or garimella@iicindia.com.
I am very happy if you provide your mail for contacting purpose(it's a request).
Thanks and Regards,
sreedhar garimella.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I consider servlet aliasing as part of the registration process. To set up a servlet alias you need to tell the servlet engine that the servlet exists. A fully unregistered servlet (one whch is just placed in a directory monitored by a running server) can only appear by its own name and location.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My email details are available (just click on the small image with the '?' attached to any of my posts) but I much prefer to answer questions on this site. If you post a question here other people can also add useful answers, and all the answers are available to help everyone.
I do not guarantee to reply to personal emails.
 
Sridhar Garimella
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frank,
You mentioned A fully unregistered servlet (one whch is just placed in a directory monitored by a running server) can only appear by its own name and location.I created one servlet(unregistered) named "Example.class" which is in the directory c:\javawebserver1.1\servlets\omnijobs.I created alias like this
alias name servlet
---------- --------
login.html omnijobs.Example
In browser if i give like this http://localhost:8080/login.html
it works properly.Here my servlet appears with different name and further login.html is not actually exists.That means there is no concept of location at all.In this senario what's actually
happened?
Thanks in advance,
sreedhar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic