You are on page 1of 3

After developing the struts application and deploying it is the server & when you start the server

then following things will happened:------------ Container initializes(read the data) the web.xml When container is reading the data from web.xml container checks all the servlets configured if they contain <load-on-startup> tag then the container try to load the servlet into the main memory . In our case we are configuring only one servlet called ActionServlet with <loadon-startup> tag Because of this container loads the ActionServlet into the memory, instance will be created and then init() method will be called. Inside the init() method they implement the code using SAX parser to read the data from struts configuration time(to file which you are passing as init parameter) once init() method is completed , all the data from struts configuration file will be loaded into main memory. If any problem happened while passing the xml documents error will be located/reported to log file and may not allow tomcat startup. //every xml must be validated When you send the request to PostProblem.jsp to display that in the browser following things will happened: ---1) 1st request will be given to ActionServlet 2) ActionServlet receive the request and then delegate the request to request processor. 3) Upon receiving the request, request processor starts processing the request by doing the following things Incoming request uri(form tag action attribute value) will be compared against path attribute value of action tags configure in action mapping . if the mapping action is not found. Then the error message (500)called cannot retrieve mapping for the action/post99 it will be display to client. If the matching action is found then its name attribute value will be taken With that name RP (request processor) verifies all the form-bean configured to check any form bean tag name is mapping with. If no names is matching with the given name then error message called cannot retrieve definition for from bean PForm will be display to the client. If it(form-bean definition) is found then its types attribute value will be taken which is nothing but form bean java class fully qualified name. form bean java class will be verified if it is not found then error message called Exception creating bean of class If the class is found then it will be loaded and it will be instantiated and initialized. The form- bean object will be stored in the given scope (value of scope of scope attribute)

The requested JSPs display to the client (PostProblem.jsp) If the scope is request then in form-bean java class ,for each request one instance will be created and initialized . But if you dont specify the scope then the default scope session is taken . in this case for every request only one instance of form-bean java class is created and default value will be initialized to this object. The name of the attribute in JSP and in form-bean java class should be same. When you are writing the uri for the JSP to display it in the browser .after hitting it then you are sending one request to this JSP. When user click on submit button after entering the value in the fields then following things will happened :--- Request will be submitted to ActionServlet ActionServlet delegates the request to request processor . Request processor identify the corresponding action for the incoming request . RP(Request processor) identify the form bean-name and then its type. RP retries or creates the form-bean object(creating in case of scope request otherwise retrieve). RP Populate the clients submitted into form bean object. RP takes the types of the action (Action class name) Action class will be instantiated if request is coming to that Action class at the 1st time otherwise already created instance will be retrieves from application scope(for many users and many browser) RP invokes the execute() method by passing the follow four parameter: -------------- ActionMapping ActionForm ActionHttpRequest ActionHttpResponse

Code inside the execute() method interacts with the model component and gets the result after processing the results action forward object will be returned by the execute() method to request processor(RP). RP takes the returned action forwarded object(which is associated with forward name) and identify the corresponding forward in struts configuration files RP takes the path (Jsp) specified for the identified forward and the same (JSP)will be forwarded to the client

A comparable object is capable of comparing itself with another object. The class itself must implements the java.lang.Comparable interface in order to be able to compare its instances. A comparator object is capable of comparing two different objects. The class is not comparing its instances, but some other classs instances. This comparator class must implement the java.util.Comparator interface. here are list of differences: 1) Comparable is used for natural ordering while Comparator is for custom sorting. 2) Comarable in java.lang package while Comparator is java.util 3) Comparable requires CompareTo() method while Comparator requires compare() method 4) CompareTo() is used in SortedSet and SortedMap e.g. TreeSet and TreeMap. 5) compareTo must be compatible with equals i.e. if two objects are equal via equals method compareTo method must return "0" for them, failing this may result in some subtle bug when you store those objects in collection class like TreeSet and TreeMap. 6)If you want to sort a collection using its comparable interface, you simply call the static Collections.sort method on it so if we had an ArrayList called Animal which implemented Comparable, we could write: Collections.sort(Animal); while To sort a collection using a Comparator class, you need to pass an extra parameter into the Collections.sort method that parameter being an instance of a Comparator object. Thus: Collections.sort(Animal, new ByBreed()); Wrapper class It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.

http://www.javabeginner.com/learn-java/java-singleton-design-pattern

You might also like