spring-mvc

spring mvc: image upload to an image server to retrieve resized image

Hi I've been working on spring mvc 2.5 and I have a situation where I need to upload an image to an image server, have it configured with tomcat so that I cold use that image server to resize the image and then get it retrieved in views. Could someone help me with an approach or user guide on how to do it? Many thanks. ...

Spring 3.0 HEAD Requests

Hi recently we moved to spring 3.0 Controller handling like this: @Controller public class MyController { @RequestMapping(method = RequestMethod.POST) protected String onSubmit ( Form form, Errors errors) { // handle POST } @RequestMapping(method = RequestMethod.GET) protected void getForm ( Form form ) { ...

Validate input field to display another input field on the same page

Hello using spring 3.0 I have page on web flow which has a password input field once the user finishes entering password i need to validate the password if it is right then display email id input field on the same page. How can i achieve this in flow? Thanks ...

DataSource not injected to @Resource annotated field with alwaysUseJndiLookup setting

Hello! I've just read about @Resource annotation from this article (http://www.infoq.com/articles/spring-2.5-part-1) and wish to use it on Tomcat 6.0.26 and Spring 3.0.3 But it does not work -- field ds in Users class does not initialized and I've got NullPointerException when I try to made a query. File src/org/example/db/Users.java ...

Spring Web MVC: Pass an object from handler interceptor to controller?

Currently I am using request.setAttribute() and request.getAttribute() as a means to pass an object from a handler interceptor to a controller method. I don't view this as an ideal technique, because it requires that I take HttpServletRequest as an argument to my controller methods. Spring does a good job hiding the request object from ...

Send Email or Logged Error on 404 and 500 Http Error Spring MVC

I have been thinking, how is it possible for me to send an email when a particular HTTP Error code happens in my Spring MVC Web app. Please take a look at my web.xml configuration. It works fine and redirects me to the particular error page. <web-app ...> <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-...

<context:property-placeholder> variables not accessible to the child (web) context

A typical use-case: I'm having applicationContext.xml and dispatcher-servlet.xml. In the parent context (applicationContext.xml) I have: <context:property-placeholder location="classpath:application.properties" /> However, the variables loaded by it are not accessible to the web context - neither in xml, nor using @Value. (They are j...

i18n : Umlaut not being displayed correctly in JSP

Hi All, I have a JSP that is supposed to display some German text from some .properties files by using fmt:message, e.g. The corresponding entry in the .properties file is: service.test.hware.test = Hardware prüfen (umlaut between r and f in 2nd word). On internet explorer this displays as: Hardware prüfen the umlaut being corr...

Spring MVC: JSP or JSON view in Controller method depending on request

Using @ResponseBody my controller returns a JSON representation of my pojo by default, but is possible to change the view to JSP by default, and return a JSON response only when your content type is application/json? @RequestMapping(value="/myRequest") public @ResponseBody myPojo myRequest() throws Exception { return service.g...

POST parameters mysteriously eaten after using spring security & an ntlm filter.

I have a custom filter that carries out spring security authentication by checking in a database, and another that checks an NTLM provider. The problem is this: Enter URL http://myapp.com/app/somestuff/stuff Get redirected to http://myapp.com/login.jsp Enter correct login details and authenticate. All forms on both http://myapp.com/...

Unit testing controllers with annotations

Hi there, I'm trying to write some unit tests for my controllers in a Spring MVC web app. I have already got a fairly comprehensive set of unit tests for the domain model, but for completeness I want to test the controllers too. The issue I'm facing is trying to test them without loading a Spring context. I thought I could get around...

Spring serving static content with mvc:resources, invalid xsd

As recommended by http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html#mvc-static-resources I wish to use <mvc:resources> for serving my spring static content. I have tried the following XML, but the .xsd file doesn't contain a declaration for <mvc:resources> and I cannot find an alternative .xsd. I ...

spring mvc dao and service bean mapping

I am new to Spring and hibernate. I am trying to learn the best practices and design methodoligies in j2ee apps. I have a managed to create a basic spring mvc web app. now lookin for that - how should i map my service beans to dao beans or should just use dao beans only. - Is there any need to make DAO classes singleton - If i use s...

update table using spring mvc web and hibernate

hi, I have simple spring mvc web application which can handle simple book store. I have a problem when the existing book is updating. I want to up date title of a book. My updateBook.jsp is somethig like this. <form method="post" action=""> Previous book title : <input type="text" name="previousTitle" /> <br> New book title :<i...

authorization stringtemplate

it doesn`t working web.xml <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/jshop-servlet.xml, /WEB-INF/applicationContext-security.xml </param-value> ...

Spring Framework filter, bean not injected

There are 2 entries for a Servlet Filter, one in web.xml and one in Spring applicationContext.xml I added the filter into applicationContext.xml because I wanted to inject creditProcessor bean into it. The only problem is that the entry in web.xml got picked up by JBoss and then used, so creditProcessor is null. Do I have to use Sprin...

Spring MVC form:errors not showing up

Apologies if this question has been asked before. I'm hoping that someone can step in and help me figure out why my form validation errors aren't showing up. I'm using Spring 3.0.3 and Hibernate, and I'm using jsr-303 validation to validate my form inputs. I have a Spring controller that handles GETting a page that contains a form that...

Integrating Spring-MVC for page navigation & RESTEasy for REST service calls (Ajax)

Hi, I'm on a project that requires Spring-MVC for page navigation (possibly with webflow) where certain pages use RESTEasy to make Ajax calls (with JSON). I found an approach on DZone JavaLobby and followed it's approach (server is JBoss): I have configured the project so that it uses Spring MVC for page navigation and REST calls as re...

From where to serve multi-Resource Web UI pages in a RESTful architecture?

Almost all web content can be a resource to be served up on its own. Web front-ends, however, mix unconnected resource content in order to serve the user with some desired experience. A blog page might be laid out with its articles stacked on the left and a list of the site's other popular blogs on the right, as an example. Let's say ...

Spring 2.5 and Json

any body ever try this tutorial ? I follow that tutorial, but I've got 404 error while I access hello.json. I'm new at code java application with spring, may be there some mistake with my configuration file. My project name is jsonapp web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-...