I am currently on the initial steps of developing a web access platform to an application.
I am thinking to use a simple Servlet to pass http requests into a state-engine. That processes the event and the details from the web page. It then queries an underlying Business Service Layer (Stateless Session beans) then builds HTML string and returns it. Is there a better way??
bcoz u r somewhat new to web first try to work with servlets and then use jsp.
ur way is ok.but if u have more than 1000 line to display
what will u do??for that purpose u cant use like this.
I think using JSP is very good for presentation layer because if you have so many different reports to print but the report headers are the same, in this case I think JSP is the best way to do. And very easy to maintain as well.
But I would prefer using Servlet to get the user inputs from web since there might be some validations need to be done when the server got the inputs.
Please tell me what you guys think.
Ben, there are much better ways than what you proposed. To build HTML strings from servlets is terribly hard to maintain. Working with JSP's makes UI design infintely simpler and easier than dealing with strings in a servlet.
The standard architecture is to keep your logic in the servlets, and return light weight data beans that contain the result of whatever logic you need to execute. You then pass these beans to a JSP and it gets the data it needs to populate itself from the beans.
Check out this pattern I posted
, for more info.
Thanks Floyd will do
surely that means that you have yo have the state of your
browser/web server session mapped through the JSPs??
Do you mean not to use a state machine ??
I am not sure what you mean. Stateful information should be stored in uses HTTPSession, and this type of logic should be stored in Servlets.
I have never used a state machine based architecture, but I heard that Trilogy uses one for their solutions.
There are approaches to this problem (so-called web templates) which are superior to JSP. They are all based on the Model/View/Controller (MVC) design and deployment pattern, which JSP unfortunatelly doesn't support.
In that architecture, the model is your typical back-end representation of the behavior of the system you are modeling. The view is the appearance of the system (in this case, a collection of HTML documents displayed in the browser). The controller is the brains of your application, interpreting user actions, deciding how to manipulate the model in order to prepare the dynamic content, and finally deciding which view (HTML document) to ship back to the user.
The most important thing to remember is: never allow for any programming in the view! That is the only way we can keep web page designers working in parallel with web developers.
Also, never allow for any rendering and formatting to occur in the model or in the controller. There shouldn't be a single line of HTML in your model/controller layers. In the same vein, there shouldn't be a single line of code in your HTML document.
Such clean separation of code and content is absolutely necessary for any real life web development project. Unfortunatelly, Javasoft made a blunder with the JSP architecture and didn't provide for a clean de-coupling of layers. This is probably due to the fact that they have followed their own prescription, as defined in the swing package, to combine the view and the controller in the so-called UI delegate. This bastardized approach to MVC is nothing but trouble.
There is no doubt that many will point that it would be possible to achieve a clean implementation of MVC architecture using JSP. This is true. However, it would require that we go out of our way and fight the JSP architecture in order to accomplish the clean MVC implementation. It would be equivalent to saying that it would be possible to achieve a Java-like error handling in Visual Basic -- true, but extremely impractical.
Which is faster JSP or servlets ? I find that Servelets are super fast while JSP is not that fast .
Also if i use EJBs will the speed of my application be affected ?