Search This Blog

Friday, 30 November 2012

Upload and Download files- continued

In the previous post we saw how to process the MultipartFile parameter. We then wrote code to convert it into a byte array and use it in our code. This all works fine.
However we have seen custom editors that are capable of converting string parameters in HttpServletRequest into objects

Thursday, 29 November 2012

Upload and Download files

We often come across scenarios wherein we need to upload a file and save it on some persistent storage. We also then have to provide code for downloading the file - this involves processing the request, reading the file - from database or file system and writing it back to the response.

Tuesday, 27 November 2012

Resource Loading in Spring

We have seen the various capabilities provided by the ApplicationContext. These include I18N, property file loading and event publishing. In this post we shall look at another utility functionality provided by the ApplicationContext - access to low-level resources.

Processing Parameters in Spring

Any web application will need the ability to process request parameters. Spring provide support for direct access to request parameters. But how do we get to the Request object ? Or can we manage without it ?

Sunday, 25 November 2012

Replicating Records Across Tables

There could be a scenario where we need that records from one database to be copied to another database.
Maybe we have an application and we would like to copy its data into another database for analysis. It could be that running export scripts is not an option. Hibernate in this case provides us with the ability to read the data from the table in one database and insert it into another table in the second database. Or to put things better, Hibernate allows us to replicate the objects.

Saturday, 24 November 2012

Springs' ContextLoaderListener

In an earlier example we show how to load beans from multiple configuration files. This is mostly needed in web applications where we write the different bean definitions in different layers.

Friday, 23 November 2012

Importing from other configuration files

One of the best practises we follow in Application development is modularity. Separation of concern is an important design practise that can also be applied to our XML configuration.

Monday, 19 November 2012

gzip your Tomcat response

I was looking at the request and response headers in our application the other day. I noticed that the Browser request included the Accept-Encoding header. The values indicated my browser was capable of handling zipped responses.

Saturday, 17 November 2012

The Hibernate Inheritance Mechanism - Flashback

OK, this is a little late. I needed to use inheritance and was going across the earlier posts - as I barely remembered how I had done inheritance in the first place. As I looked at the four techniques and the mutated enhancement provided by Hibernate I saw certain things that I had failed to note down the last time.

Thursday, 15 November 2012

Using annotation based handler mappings

In earlier posts we saw the different URL handler mappings available to enable the servlet to route requests to correct controllers. Spring has also introduced annotation based controllers.

Tuesday, 13 November 2012

Using Multiple URL Handler Mappings

As we saw earlier Spring supports a variety of URL handler mappings. In fact we can use multiple URL Handler mappings in the same application.

Sunday, 11 November 2012

Forcefully initializing proxies in Hibernate

As we have seen, The Hibernate Entities that we load in a persistence context may be made of proxies and collection wrappers. The simplest way to initialize these proxies would be to call any of the data getter methods (except Identifier).

Friday, 9 November 2012

Spring MVC without URL Mappings ?

In an earlier example we saw that Spring uses a single front-controller servlet. The Servlet then delegates the request to the controllers. This was achieved by mapping the controllers to urls.

Tuesday, 6 November 2012

The ModelAndView

In our previous example we did not explore the ModelAndView object in detail. We simply passed the control to a static jsp page. I modified the example to deal with a jsp with some dynamic content.

Sunday, 4 November 2012

Basic MVC application in Spring

Spring provides support for MVC based web application development. I decided to create a very basic application involving a simple HTML page and a JSP page.

Friday, 2 November 2012

Eager fetching does not work for parallel bags

In our previous posts we saw how Hibernate allows the use of eager fetching for collections. We also saw that with more than one collection having eager fetch enabled, how the Cartesian product problem was encountered. But this problem will never occur with Bags. Why? Because bags do not support this feature.