This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Do you use any guidelines to design servlets in an application? I mean do you use a single servlet to handle all form actions(on end) or you use one servlet for each form action(the other end)? Are there any performance issues etc. that should be considered when designing? Another quick question: Is there any html tag that equivelant to jsp's include directive to include another html file? Thanks, Peter
Microsoft FrontPage has an extension to allow for included files. Also, you can include pages using SSI (though different servers have different syntaxes for it) On IIS, you do: <!--#include file=filname--!> HTH Brian
"peter, pan", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements. Thanks.
Hi, For including files in JSP use the RequestDispatcher object. Such an object can be obtained by calling the ServletContext`s getRequestDispatcher() method.Then you can use the include() method of the RequestDispatcher object.
Originally posted by peter, pan: I mean do you use a single servlet to handle all form actions(on end) or you use one servlet for each form action(the other end)?
The most powerful approach IMHO is to have a single servlet (the controller) to handle actions. The servlet would dispatch the actions to command objects that implement the actual action. The whole thing is preferably controlled from a configuration file which lists, for each action/page combination, the commands to execute. Controller and commands should all be stateless, so that they can be shared between all server threads. State belongs in the session and request objects.
Are there any performance issues etc. that should be considered when designing?
I did not have any guidelines set for when I started my first project based on servlets as server side program, but as I went on with design I found that it would be good to write one servlet each for one form to share between team members as it goes on with modularizing the design. But I din't consider the performance issue, many people whom I consulted in this area were of the view that one form per servlet does not hinder the performance
This is a good topic for discussion I would like for views of people working in this area Peter, Can you please explain your design views in little more detail Regards
[This message has been edited by narayan kulkarni (edited February 06, 2001).]
Take up computer programming as fun and you will just enjoy it. Always keep in mind that in some way your program is going to make human life easier.