home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Spring Framework example source code file (ViewCartController.java)

This example Spring Framework source code file (ViewCartController.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Spring Framework tags/keywords

cart, cart, controller, controller, exception, http, httpservletresponse, modelandview, request, response, servlet, string, string, usersession, usersession, viewcartcontroller

The Spring Framework ViewCartController.java source code

package org.springframework.samples.jpetstore.web.spring;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.samples.jpetstore.domain.Cart;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.util.WebUtils;

 * @author Juergen Hoeller
 * @since 30.11.2003
public class ViewCartController implements Controller {

	private String successView;

	public void setSuccessView(String successView) {
		this.successView = successView;

	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
		UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
		Cart cart = (Cart) WebUtils.getOrCreateSessionAttribute(request.getSession(), "sessionCart", Cart.class);
		String page = request.getParameter("page");
		if (userSession != null) {
			if ("next".equals(page)) {
			else if ("previous".equals(page)) {
		if ("nextCart".equals(page)) {
		else if ("previousCart".equals(page)) {
		return new ModelAndView(this.successView, "cart", cart);


Other Spring Framework examples (source code examples)

Here is a short list of links related to this Spring Framework ViewCartController.java source code file:

my book on functional programming


new blog posts


Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.