Tuesday, June 08, 2004

userRegistration

To get a handle on Struts and Spring for as400 web dev, im working through Struts Live, and trying to get each example working in the Struts/Spring combo as I go along.

Im running this stuff on tomcat 4.1.29 and using Eclipse M9 as my IDE (Luv it!)

Configured web.xml for the Struts ActionServlet

<servlet>
<servlet-name>action<//servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
<//servlet-class>
<init-param>
<param-name>config<//param-name>
<param-value>//WEB-INF//struts-config.xml<//param-value>
<//init-param>
<load-on-startup>2<//load-on-startup>
<//servlet>

The first example action is strutstutorial.UserRegistrationAction, and all that does is to request a forward to the view "success".

return mapping.findForward("success");

The success jsp is as simple as

<html>
<head>
<title>
User Registration Was Successful!
</title>
</head>
<body>
<h1>User Registration Was Successful!</h1>
</body>
</html>

Add an action mapping to Struts config to url to the action handler class by adding the following to \WEB-INF\struts-config.xml

<action path="//userRegistration"
type="strutsTutorial.UserRegistrationAction">
<forward name="success" path="//regSuccess.jsp"//>
<//action>

i deployed this stuff to tomcat, and it worked. Now to change this to work with Spring.

Added the relevant jars to my eclipse project from the Spring distribution.
Added the struts-spring plugin jar

Added a reference to the plugin in struts-config.xml

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="//WEB-INF//spring-beans.xml"//>
<//plug-in>

Modified the type on the action mapping in struts-config.xml

<action path="//userRegistration"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="//regSuccess.jsp"//>
<//action>

Reference to the action class in spring-beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-////SPRING////DTD BEAN////EN"
"http:////www.springframework.org//dtd//spring-beans.dtd">

<beans>

<bean name="//userRegistration"
class="strutsTutorial.UserRegistrationAction">
<//bean>

<//beans>

i thought that this should have been enough, but when I ran the app on Tomcat I got an error because applicationContext.xml could not be located. So i create a blank one in WEB-INF.

Pointed at the URL, and this worked, yeah my first meaningful foray into Struts and Spring. as400 web dev here we come

Monday, June 07, 2004

Jakarta Struts Live

Ive worked through something to help with as400 web development. The Spring MVC tutorial Developing a Spring Framework MVC application step-by-step and also read Spring DAO and JDBC support to get some background on Spring.

One of the benefits I should get from Spring is that ability to have all my database access logic in one place, which at the moment is the bulk of the complex code in my web apps.

Im also reading Jakarta Struts Live by Rick Hightower. This looks like a single reference that I can use to get to grips with Struts, and then combine this with Spring to build my as400 webapps

Spring and Struts on as400

Spring and Struts on as400

Over the last week I have been trying to find a way to make the as400 web development that i have been doing less "on the fly" and more robust.

Im looking for the "framework" that will give me a repeatable development cycle that I can use consistently but have the flexibility and acceptance to build and and grow with in the future. The ones that seem to match up quite well are Spring and Struts.

Struts appears to be the current front runner for building the front end stuff for the web app, and Spring is a good framework for holding together the backend.

Ive still got websphere deployment automation stuff, and as400 web application testing (currently im using Jameleon / Httpunit combo, which works up to a point) that I want to do, but ill hold off on those for a while, till I get my head round Struts / Spring

as400 webapp deployment