Struts Flow
Frame work semi implemented application which will provide very good environment to simplify and excellerate the application development.
two types of framework
web appliction framework--Struts and JSF
appln frame work--spring
web.xml
it provides mapping between URL pattern and ActionServlet class which is available in struts framework.
has welcome file
*/
private static TokenProcessor token = TokenProcessor.getInstance();
// NOTE: We can make the tken variable protected and remove Actions
// token methods or leave it private and allow the token methods to
// delegate their calls.
// ----------------------------------------------------- Instance Variables
/**
*
*/
protected transient ActionServlet servlet = null;
// ------------------------------------------------------------- Properties
/**
*
*
* @return The servlet instance to which we are attached.
*/
public ActionServlet getServlet() {
return (this.servlet);
}
Frame work semi implemented application which will provide very good environment to simplify and excellerate the application development.
two types of framework
web appliction framework--Struts and JSF
appln frame work--spring
web.xml
it provides mapping between URL pattern and ActionServlet class which is available in struts framework.
has welcome file
Whenever any web application is deployed an object will be created ie ServletContext Object for each web Application Ex: Login Application
At the time of recognizing our application Container identifies web.xml performs loading and parsing of web.xml file
At the time of recognizing our application Container identifies web.xml performs loading and parsing of web.xml file
Difference between include action and forward action.
Difference in output.ex: if we forward from one.jsp to two.jsp the contents of only two.jsp will be generated .
if we include two.jsp in one.jsp the contents of both the jsp's will be generated
Why servlet is used as controller ?not JSP? i want complete Explation?
In struts servlet control the application and we know that a jsp compiled into a servlet first. The only problem with the servlet is that it needs to write out.println call per HTML line. But as a controller in struts servlets do not force the programmers to write out.println, that is the part of JSP which acts as View.
So if the controller would be JSP the translation (JSP compiled to a servlet)step would be of no use and it only affets the performance of the system.
Most of the applications are created in MVC design pattern to seperate the functions of differnet components and handle the complexity of applications. JSP and Servlets are the server side components which can respond to the client request.
Servlets are the basic components for request handling in Web Server. They contains pure Java code. Everything that needs to be done to generate the proper user response (which is genarally HTML code) needs to be done through coding. As a single servlet cannot respond each and every request by itself as client request varies in type (e.g. enquiry, update request, add etc) the request and response object is passed onto different servlets with little task completed by each servlet. This controlling part is easier to write in java. So Servlet is used as controller.
JSP is again a servlet which has syntax more like to HTML with java support. Whatever user is going to see as result of his request is HTML. Programmer can easily write html tags inside JSP to render html. This is very economical to change also. So all this code is written JSP which is (generally) the final link in Servlet chaining
To maintain the control flow huge amount of code is required.Writing huge code in jsp is against jsp technology.
So Jsp is not recommended to use as a controller
What is difference between Html tags and Struts specific HTML Tags
1. Html tags are static Struts tags are Dynamic( At the run-time struts tags are called)2. Another diff is U create ur own Struts tags
Struts tags bind the property value with the Formbean property defined.
Well from end users perspective, not much of a difference.
From programmers perspective, it can be said that each struts html tag would be mapped to an attribute of a form bean.
Another thing we can state is that we can define our own custom tags which isn't possible in html.
HTML tags are static and Struts tags are dynamic.
Struts tags can be created by the page authors.
Binding of the property value with the Formbean property is done by the Struts tags.
HTML tags support the templates and themes.
Struts have HTML tag libraries and thus HTML tags are integral part of Struts
Is Action class is Servlet or Not ? if yes why ?
In
Struts1, Action Servlet is a servelet (since it extends HTTPServle) but Action
class extentsorg.apache.struts.action.Action which has nothing to
do with Servlet.
In Struts2, Action class extends com.opensymphony.xwork2.ActionSupport which has nothing to do with Servlet.
So, to answer the question, Action class is not a Servlet by any logic.
In Struts2, Action class extends com.opensymphony.xwork2.ActionSupport which has nothing to do with Servlet.
So, to answer the question, Action class is not a Servlet by any logic.
No,
Action Class is not a servlet, Because it is not a subclass of
javax.servlet.GenericServlet. An ActionServlet calls the execute() method of an
ActionClass().
Action
class is not a Servlet .
Any Java object which extends the functionality of servlet interface or HttpServlet or GenericServlet or it is subclass can be called as a servlet but our action class does not extend any of these.
For clarification go to web.xml, there we have to define all the servlets. You will not find Action class bec it is not a servlet.
Any Java object which extends the functionality of servlet interface or HttpServlet or GenericServlet or it is subclass can be called as a servlet but our action class does not extend any of these.
For clarification go to web.xml, there we have to define all the servlets. You will not find Action class bec it is not a servlet.
Actually
the confusion is between two classes Action
and ActionServlet. Be clear that these two are different classes. ActionServlet
is a servlet but Action is a normal java class.
Was this answer
useful? Yes
Reply
No Action
class is not a servlet since it is not overriding init(),service,destory
methods at the same time its super classes are also not implemented these three
methods.One thing i want to say is any servlet in the world should implement
Servlet interface either directly or indirectly .But action class is not
implementing like that so it is not a servlet
Was this answer
useful? Yes
Reply
No. the
Struts action class neither extend any class nor implement any interface.
More over it has defined one method getServlet() .. discribes which servlet it associated with it. This will be Action Servlet, unless your write ur own Action Servlet.
public class Action {
/**
*
More over it has defined one method getServlet() .. discribes which servlet it associated with it. This will be Action Servlet, unless your write ur own Action Servlet.
public class Action {
/**
*
An
instance of TokenProcessor to
use for token
* functionality.
* functionality.
*/
private static TokenProcessor token = TokenProcessor.getInstance();
// NOTE: We can make the tken variable protected and remove Actions
// token methods or leave it private and allow the token methods to
// delegate their calls.
// ----------------------------------------------------- Instance Variables
/**
*
The
servlet to which we are attached.
*/
protected transient ActionServlet servlet = null;
// ------------------------------------------------------------- Properties
/**
*
Return
the servlet instance to which we are attached.
*
* @return The servlet instance to which we are attached.
*/
public ActionServlet getServlet() {
return (this.servlet);
}
No..
Action class is not a servlet. The only servlet class in plain struts framework
(without spring etc.) is ActionServlet.
Action class is not a servlet but
it is having the properties like a servlet. For example servlets have request
and response objects similarly action classes is also having request and
response objects. So we can say action classes are having the servlet behaviour
but they are not servlets. Since servlets are having init, service and destroy
methods are there but action classes are not having these ..