Simple
Application Use Servlet Part I
Servlet
is a java class can accept request from another java class, web
client or other servlet, which can trigger the response, Sometime
servlet is named HTTP
Servlet
because servlet were used combine with HTTP, but servlet itself not
one of client server protocol specification.
We
can make web application in java use servlet, in web
application there are many request-response process and make a lot
servlet then make it our application is hard to maintain, web
application requires a
centralized access point for HTTP request handling to support the
integration of system services like security, data validation
etc, content retrieval, view management, and dispatching. When the
user accesses the view directly without going through a centralized
mechanism, few problems may occur :
- Each view is required to provide its own system services often resulting in duplicate code.
- View navigation is left to the views. This may result in shared code for view content and view navigation.
- Distributed control is more difficult to maintain, since changes will often need to be made in numerous places.
Generally
we write specific servlets for specific request handling. These
servlets are responsible for data validation, error handling,
invoking business services and finally forwarding the request to a
specific JSP view to display the results to the user.
According
that we better only have one Servlet (instead of having
specific Servlet for each specific request) centralizing the handling
of all the requests and delegating the functions like validation,
invoking business services etc to a command or a helper component.
The benefit that we have only one servlet are :
- Avoid duplicating the control logic like security check, flow control etc.
- Apply the common logic, which is shared by multiple requests in one controller.
- Separate the system processing logic from the view processing logic.
- Provides a controlled and centralized access point for your system.
As
I describe about let’s gather requirement for making simple
application using servlet.
Tool
:
- java JDK 1.6 or above because all servlet management such as naming, mapping or url pattern, initial params, because we can use annotation. I used Java JDK 1.7.
- server I used tomcat 7
- editor Eclipse Indigo
- for storing data, I will use Collection class, map and stay in JVM in singleton state
Application
process constraint:
- user can log in to application and can edit his/ her profile after save the page will be directed to login form. For checking that the profile has been change user just login again and she/ he will see the profile and edit again.
- If user not register yet, can go to page sign up after finish entry all data and submit user will be directed to login form and For checking that the profile has been change user just login again and she/ he will see the profile and edit again.
Good Blog,
ReplyDeletePost Free Ads, Free Classified site http://ooa.bugs3.com