Currently Browsing

Posts Tagged ‘ Spring ’

Binding data with Spring Forms

Spring has its own tag library, which makes JSPs easier to develop, maintain and read. One of these libraries is the form tag library, and in this post we’ll demonstrate how to use it.

For this we will use a sample project that will let us modify the user’s account details. In order to display the stored values for the account in the form, we have previously tied an object named foo to the session that holds all the information about our user’s account.

The form used for displaying and sending the account data is displayed here:

<form action="/account" method="post">
	<fieldset>
	<legend>Edit account information:</legend>
	<table>
		<tr>
			<td><label for="name" >Name:</label></td>
			<td><input type="text" id="name" name="name" value=${foo.name} /></td>
		</tr>
		<tr>
			<td><label for="email">E-mail:</label></td>
			<td><input type="text" id="email" name="email" value=${foo.email} /></td>
		</tr>
		<tr>
			<td><label for="website">Website:</label></td>
			<td><input type="text" id="website" name="website" value=${foo.website} /></td>
		</tr>
		<tr><td>&nbsp;</td><td><input type="submit" value="Save" /></td></tr>
	</table>
	</fieldset>
</form>

Now lets do the implementation of the form tag library on this code:

Servlet Mapping for Google App Engine and Spring

This post is all about Spring MVC 3 and Google App Engine and their interaction.

The starting point for this project was the Google App Engine’s documentation, the Google Eclipse plugin, and some tutorials found on various sites.

After reading all about the App Engine and Spring, the first thing to do was to create a project in our favorite editor, Eclipse. This generated some necessary files, and gave us a good starting point. As we want to use Spring to perform all its magic, we’ve created a web.xml like this:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>