CSE 510 Web Data Engineering
The Struts 2 Framework
UB CSE 510 Web Data Engineering
CSE 510 Web Data Engineering The Struts 2 Framework UB CSE 510 Web - - PowerPoint PPT Presentation
CSE 510 Web Data Engineering The Struts 2 Framework UB CSE 510 Web Data Engineering Whats The Difference? A new framework that implements the MVC It is said to be simpler for development Features: Action : implements an Action
UB CSE 510 Web Data Engineering
UB CSE 510 Web Data Engineering 2
UB CSE 510 Web Data Engineering 3
welcome ¡
Welcome.do ¡ CheckBid1.do ¡ Buy.do ¡ ccForm ¡ Start ¡
forward ¡
PageA1.jsp ¡
Place ¡Bid ¡ (bu?on) ¡
PageB.jsp ¡
highestBid ¡ success ¡ Buy ¡ (bu?on) ¡ !validate ¡
bidForm1 ¡
failure ¡
PageA2.jsp ¡
notHighestBid ¡
CheckBid2.do ¡
Place ¡Bid ¡ (bu?on) ¡ !validate ¡
bidForm2 ¡
notHighestBid ¡ highestBid ¡
UB CSE 510 Web Data Engineering 4
show.acGon ¡ checkBid.acGon ¡ buy.acGon ¡ Start ¡
result ¡
PageA1.jsp ¡
Place ¡Bid ¡ (bu?on) ¡
PageB.jsp ¡
highestBid ¡ success ¡ Buy ¡ (bu?on) ¡ input ¡ error ¡ error ¡
PageA2.jsp ¡
notHighestBid ¡ Place ¡Bid ¡ (bu?on) ¡
UB CSE 510 Web Data Engineering 5
<filter> <filter-name>struts2</filter-name> <filter-class>
</filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
UB CSE 510 Web Data Engineering 6
UB CSE 510 Web Data Engineering 7
UB CSE 510 Web Data Engineering 8
<action name="checkBid" class="app.actions.CheckBid"> <result name="input">/pages/PageA1.jsp</result> <result name="error">/pages/PageA1.jsp</result> <result name="highestBid">/pages/PageB.jsp</result> <result name="notHighestBid">/pages/PageA2.jsp</result> </action>
UB CSE 510 Web Data Engineering 9
UB CSE 510 Web Data Engineering 10
UB CSE 510 Web Data Engineering 11
UB CSE 510 Web Data Engineering 12
UB CSE 510 Web Data Engineering 13
UB CSE 510 Web Data Engineering 14
public class MyAction implements ModelDriven, ServletRequestAware { private HttpSession session; private HttpServletRequest request; private FormBean bean; // objects defined by me public void setServletRequest(HttpServletRequest request) { this.request = request; this.session = this.getSession(); } public FormBean getModel() { bean = (FormBean) session.getAttribute(FormBean.NAME); if (bean == null) { bean = new FormBean(); bean.setAttribute(FormBean.NAME, bean); } return bean; } public static class FormBean { // setter getter } }