Hakan Axheim

+ Follow
since Nov 24, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hakan Axheim

I have solved this problem. I had different versions of spring.jar and spring-web.jar.
Everything works as expected!

10 years ago
Well the source code I give to you is the Controller that should handle the update.
The JSP page I have posted is the update page - this JSP page should handle the update.
I'm a newbie at Spring therefore my questions.

When I cklick on the Submit button on the web page (see JSP page in this thread) the onSubmit method will be called but the new entered value will not be sent to that method!
I don't know what you mean by putting projectID in the session.

When the JSP page listed in this thread (updateProject.jsp) will be called it receives a projectID and the formBackingObject method will be called.

10 years ago
JSP file for updating a record:
10 years ago

package BL.controller;

import javax.servlet.http.*;
import javax.servlet.ServletException;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.bind.RequestUtils;
import org.springframework.validation.BindException;

import BL.Project;
import BL.service.ProjectServiceImpl;
import IL.util.DAOException;

public class UpdateProjectController extends SimpleFormController {

// private static final Logger logger = Logger.getLogger(UpdateProjectController.class.getName());
ProjectServiceImpl projectServiceImpl = new ProjectServiceImpl();

public UpdateProjectController() {
logger.info("Current: Inne i UpdateProjectController --> Constructor");
logger.info("Current: Constructor slutförd");

protected Object formBackingObject(HttpServletRequest request) throws ServletException {
logger.info("Current: Inne i UpdateProjectController --> formBackingObject ");

logger.info("Current: Project ID " + String.valueOf(RequestUtils.getIntParameter(request,"projectId")));

Project project = new Project();
project = projectServiceImpl.getAllProjects(RequestUtils.getIntParameter(request,"projectId"));

logger.info("Current: Projektnamn " + project.getProjectName());

return projectServiceImpl.getAllProjects(RequestUtils.getIntParameter(request,"projectId"));


public ModelAndView onSubmit(Object command) throws ServletException
logger.info("Current: Bekräfta");

Project projectCommand = (Project) command;

logger.info("Current: " + projectCommand.getProjectId());
logger.info("Current: " + projectCommand.getProjectNumber());
logger.info("Current: " + projectCommand.getProjectName());
logger.info("Current: " + projectCommand.getStartDate());
logger.info("Current: " + projectCommand.getEndDate());

try {
} catch (DAOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
return new ModelAndView("readProject","project",projectCommand);

logger.info("Current: Projektnamn " + project.getProjectName());

Project commandName = (Project) command;

logger.info("Current: ProjectId " + String.valueOf(project.getProjectId()));
logger.info("Current: ProjectNr " + project.getProjectNumber());
logger.info("Current: ProjectNamn " + project.getProjectName());
logger.info("Current: StartDate " + project.getStartDate());
logger.info("Current: EndDate " + project.getEndDate());

try {
} catch (DAOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.

return new ModelAndView("readProject","project",project);

10 years ago

I am using Spring 2.5.x to develop a small Application.
The application retreives a number of records from a database with Hibernate.
This records are shown in a web page with a link to another web page where it should be able to change a specific record.
When I klick on the link to change a specific record a new page is shown with the specific record.
In this page I change data for a specific field and click on a Submit button.
My controller (SimpleFormController) will be executed and the formbackingobject method will be executed.
After that onSubmit method will be executed but it the new entered data will not be sent to onSubmit method.
Instead the old data will be send to this method.


Best regards


10 years ago

I have a Control class that lists all records from a database with hibernate and prestent the retrevied records in an JSP page.
In this page I have three posibilities. View more information about a specific record, update a specific record or delete a specific record.
This is don with the <a href ... tag. It was easy to delete a record and show a record. <br /> <br /> When I click on the update link I want to present a new JSP page with the all data allocated to that specific record. <br /> After that I wan't to change some data in that JSP page and click on an OK button. <br /> The OK button will then update the database with the new information. <br /> <br /> I 'dont know how to do that update scenario! <br /> Wich type of Control and which methods? <br /> Do I have to handle several controls? <br /> <br /> Maybe somone can give me an example! <br /> <br /> rel="nofollow">
10 years ago
I'm really new to Hibernate. I use both Spring and Hibernate. I am almost finished with my test application. Everything works fine and I see with MySQL Query Browser that records will be inserted into the database from my Web browser. I have also made a web page that reads records from my database and I see all my insterted records in that web page.

Now, to the strange part!

After a while - maybe 5-10 minutes all my inserted data will disappear from the database. Why? Can someone help med describe that? Is autocommit turned off? Some default value that must be changed?

This is my mapping file;

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"


<class name="businessLayer.Project" table="project">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
<property name="ProjectId" type="java.lang.Integer"/>
<property name="ProjectNumber" type="java.lang.Integer"/>
<property name="ProjectName" type="java.lang.String"/>

I'm a newbie at Spring framework therefore I need to ask a question in this forum. This is an extract from my servlet.xml file;

<bean name="/createProject.htm" class="businessLayer.controller.CreateProjectController">
<property name="sessionForm" value="true"/>
<property name="formView" value="createProject"/>
<property name="successView" value="readProject"/>
<property name="projectService" ref="projectService"/>

I wan't to create an JSP page where I enter some data regarding a project that I wan't to create. This is an extract from my createProject.jsp;

<form:form commandName="project" method="post">
<spring:bind path="project.projectNr">
<input type ="text" name="projectNr" value="${status.projectNr}"/>
<spring:bind path="project.projectName">
<input type = "text" name = "projectName" value="${status.projectName}"/>
<input type="submit" name = "Create Project" value = "Create Project"/>
<input type="reset" name="Rensa" value="Rensa"/>

My formBackingObject looks like this;

protected Object formBackingObject(HttpServletRequest request)

logger.info("Inne i formBackingObject");

try {
project.setProjectNumber(ServletRequestUtils.getRequiredIntParameter(request, "projectNr"));
project.setProjectName(ServletRequestUtils.getRequiredStringParameter(request, "projectName"));
project.setStartDate(ServletRequestUtils.getRequiredStringParameter(request, "startDate"));
project.setEndDate(ServletRequestUtils.getRequiredStringParameter(request, "endDate"));
} catch (ServletRequestBindingException e) {
// TODO Auto-generated catch block


return projectService;


and my onSubmit method looks like this;

public ModelAndView onSubmit(Object command) throws ServletException {

logger.info("Inne i CreateProjectController");


project.setProjectNumber(((Project) command).getProjectNumber());

logger.log(Level.INFO,"onSubmit: ProjectNumber ",((Project) command).getProjectNumber());

// projectDao.setProjectNr(projectNumber);

// logger.info("ProjectNr " + projectNumber);

// projectService.createProject(projectDao);

return new ModelAndView(new RedirectView(getSuccessView()));


No data will be passed in to the formBackingObject from the JSP page. I don't know why! Is it wrong in my JSP page or is it normal?

Can someone help me with this?

I have a servlet that streams an ICalendar. As you can see I have used the setContentType and setHeader method in response objekt. When I use the IE 7.0 I receive an calender.ics file that should be downloaded to the filesystem but in Firefox the extension to the filename will be deleted. So the filename will be just calendar in Firefox but in IE it will be calendar.ics.

response.setContentType("text/calendar; charset=UTF-8");

OutputStream writer = response.getOutputStream();
ICALCalendar cal = (ICALCalendar) model.get("ical");
CalendarOutputter outputter = new CalendarOutputter();
outputter.output(cal.getCalendar(), writer);


Can anyone tell me whats wrong?

13 years ago