Tuesday 3 July 2012

Rubbish

Dont read this ....
How serving webpages works ? (according to me )

we click url  and page correspondingly is served from server
we then give input and click submit
then this info is sent in request
then now 2 things can be done
1) either values are written directly in response by response.write () in the java program(servlet)
2) or use JSP ,where it is done in two ways
i) values are set in bean(bean should exists) in server and then got from bean by

<jsp:useBean id="mybean" scope="session" class="org.mypackage.hello.NameHandler" />
 <jsp:setProperty name="mybean" property="name" value="vivek" /> (sets value of the argument in url "name" and sets in bean )
 <jsp:getProperty name="mybean" property="name1"/> ( retrieves from bean)
ii) or write java code in scriptlet tag
when you create web app using struts additional files are ?
Name->Web Pages->WEB-INF ->
1) beans.xml
2) struts-config.xml
3)tiles-defs.xml
4)validation.xml
5) validator-rules.xml


Actually what we do in including struts is
actually in giving global url localhost:8080/global-url/ , it gets directed to somename.do ,,, as in index.jsp we have asked it to forward the request <jsp:forward page="somename.do"/> , this statement is equal to typing in url tab as localhost:8080/global-url/somename.do  . Dont interpret this statement as forwaring request to somename.do (as it looks smilar to redirecting to some.jsp) .. but this is eq to typing and clicking  url/somename.do .
now it goes and checks in web.xml . what to do with request localhost:8080/global-url/somename.do  
as there it is written as *.do as context path should be mapped to servlet org.apache.struts.action.ActionServlet , and also struts-config.xml are sent as parameters .........


so now thereafter it becomes regular servlet story , as  org.apache.struts.action.ActionServlet class has a reference to what i am saying. statement goes like this
 public class ActionServlet extends javax.servlet.http.HttpServlet { 
so  org.apache.struts.action.ActionServlet is our servlet java code 


and the struts-config.xml is like the original web.xml 


The idea of having this type of mapping is that they have servlet classes org.apache.struts.action.* written by themselves which does some of the basic tasks . 


As it completely deals with srtuts action , people have created their own nomenclature . like using 
<action-mapping> instead of <servlet-mapping>


No comments:

Post a Comment