Skip to main content

Re: [webtier] EL output filtering in JSP

1 reply [Last post]

I recommend making or using a custom output component like those provided by JSF.

Escape defaults to true


------Original Message------
Subject: [webtier] EL output filtering in JSP
Sent: May 11, 2009 11:05


I'm working on a JSP application (non-JSF) and I'd like to do some output filtering on every variable that is used in the JSP pages. The reason for this is security, I want to prevent cross site scripting.

We're using a home brewn MVC framework which looks a bit like Struts, so I have plenty of options regarding logic placement.

The control flow is very simple, all logic is put into Java controllers, which are executed. The controllers return the model back to the page. The framework does this by calling request.setAttribute() for each model variable. So far, so good.

The problem is, not every model variable is a simple string. For example, we pass complete domain objects (Client, Transaction, Account) back to the JSP and the JSP then walks over the object graphs.

SO, in the JSP, we have expressions like the following:

What I'd like to do, is having a hook which is called when the complete expression is evaluated. In that hook, I check if the type is a String. If so, I do some HTML escaping.

But the problem is, I don't have a place to put this code. I've looked at ELResolvers, but it looks like they work a bit different.

I'm using JBoss EAP 4.3, so Tomcat 6 as the Servlet container.

Does anyone have an idea?
[Message sent by forum member 'jkva' (jkva)]

To unsubscribe, e-mail:
For additional commands, e-mail:

Sent from my Verizon Wireless BlackBerry

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-04-06

Well, since it's an online financial system, I'd wanted to create something more generic. To make sure security is "turned on" by default.

I don't want to expect maintainers to have to think about security too much when they are modifying pages. After all, security bugs are easy to create and hard to find.