Thursday, October 26, 2006

Java alpha-numeric security image generator (CAPTCHA) libraries

I've been asked this question more than once. Are there any Java based libraries out there that can generate those skew alpha-numeric images to block bots from entering certain parts of my web-site?

Yes, of course, there are! Look at:

Thursday, October 05, 2006

Web 2.0 and scalability issues of Servlet Containers

We are often told that client side polling in a typical web-app is a poor design choice but often they don't explain why it is so. Of course, at a high level we know that each client request is associated with a server thread and the thread and it's allocated resources are blocked until the client request finishes. Therefore if we have too many polling type requests which are "no-op"s, we are potentially tying down a lot of server resources essentially serving a bunch of "no-ops" while eating a chunk of memory each.

With web 2.0 we are going to have these type of scenarios, whether we like it or not! So is there a better way? Is anybody doing anything about it? Here are two very interesting articles for anyone looking for answers to these questions:

EL expression not evaluated! ${msg} appears as ${msg} in the output!

If your JSP is printing your ${whatever} el expressions as they are, verify that:

  1. You are using a JSP2.0 compliant servlet container.

  2. Your web.xml starting tag looks like this:

    <web-app xmlns=""

Sunday, October 01, 2006

Spring Error - ModelAndView [ModelAndView: materialized View is [null]

I've been struggling with this stupid error for an hour now. Well, don't they all look stupid after they are resolved! If you searched on this exception, read on, you might just find the solution here :).
I kept getting the following exception in my controller and I just couldn't figure out what I had done wrong.

javax.servlet.ServletException: ModelAndView [ModelAndView: materialized View is [null]; model is {org.springframework.validation.BindException.recipe=org.springframework.validation.BindException: BindException: 0 errors,}] neither contains a view name nor a View object in servlet with name 'action'
at org.springframework.web.servlet.DispatcherServlet.render(
at org.springframework.web.servlet.DispatcherServlet.doDispatch(
at org.springframework.web.servlet.DispatcherServlet.doService(
at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(
at org.springframework.web.servlet.FrameworkServlet.doGet(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.mortbay.jetty.servlet.ServletHolder.handle(
at org.mortbay.jetty.servlet.ServletHandler.handle(
at org.mortbay.jetty.servlet.SessionHandler.handle(
at org.mortbay.jetty.handler.ContextHandler.handle(
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(
at org.mortbay.jetty.handler.HandlerCollection.handle(
at org.mortbay.jetty.handler.HandlerWrapper.handle(
at org.mortbay.jetty.Server.handle(
at org.mortbay.jetty.HttpConnection.handleRequest(
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(
at org.mortbay.jetty.HttpParser.parseNext(
at org.mortbay.jetty.HttpParser.parseAvailable(
at org.mortbay.jetty.HttpConnection.handle(
at org.mortbay.thread.BoundedThreadPool$

After much googling, I found nothing. Finally I turned on the DEBUG logging for spring and tried to solve it the hard way - logically.
Long story short, here's why I was getting the exception:

I had a bean mapping as follows:

<bean id="barManager"
<property name="commandName" value="bar" />
<property name="commandClass"
value="" />

I also had a URL mapping as follows:
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<prop key="/barlink.html">barManager</prop>
I kept getting the above exception when I tried to access http://localhost:8080/myapp/barlink.html
The solution to the problem was adding the following line to the barManager definition:
<property name="formView" value="bars" />
Also, the value "bars" MUST map to an existing view name. In my case, it mapped to bars.jsp.

After adding this, the definition looks like this:
<bean id="barManager"
<property name="commandName" value="bar" />
<property name="commandClass"
value="" />
<property name="formView" value="bars" />

That's it. It took me an hour and a half to figure out and about 15 min to write this. Hopefully this will save you some time :).

This page is powered by Blogger. Isn't yours?