>

Wednesday, January 16, 2013

Simple Application Use Servlet Part II Creating Baseline

Simple Application Use Servlet Part II
Creating Baseline

we will create the baseline for our simple application as we mentioned in last post, we just using one servlet for centralizing the request and response, as we know that our application not just, one request, but more. To meet this condition.
the step i chose:
  • we stay have one servlet
  • we have a lot url pattern servlet but stay one servlet and one name servlet
  • on the method doPost and doGet we instantiate only one object i will be named it CallingAction,
  • in callingAction we just call one method and pass parameter, userpath (request path/ url pattern)

    shabby note - simple application
    Baseline for Simple Application


why we create CallingAction, the idea is every time user do a request we provide by specific url pattern for each different request type, in the servlet class we can retrieve request path(url pattern name) that user hit. For handling the right method for the right url path. I chose step as describe bellow:

  • create labels for each name url pattern, method for the right request and also the class belong to the method
  • each specific url pattern has method, and has class belong to method, have the same labels name
  • based on labels that we created, by using java reflection for picking the right object and method for specific url pattern in CallingAction

For storing labels, I will use interface and grouping for each url path, method and the class belong to method, I will use interface too. The labels will have value as points bellow:
url path → url pattern name
method → method name
class →package_name.class_name

For storing data, I used Hashmap in singleton method. Every time user create user name or edited will be put in the hashmap .

No comments:

Post a Comment