Take the 2-minute tour ×

im trying to get a controller to return a view through a Expression Language-Filter, but have no idea on how to get jersey to use EL for filtering a view.

View with EL-tags:



public Response viewEventsAsHtml(){
    String view=null;
    try {
    }catch(IOException e){
        LOG.error("unable to load view from file",e);
        return null;
    Response.ResponseBuilder builder=Response.ok(view, MediaType.TEXT_HTML);
    return builder.build();

How would one go about in order to get the controller to replace the ${msg} part in the view by some arbitrary value?

share|improve this question
JSTL? How does JSTL come into the picture? Don't you mean EL, Expression Language, those ${} things in the average JSP page? Or maybe just "output formatting" with {n} as you would do with MessageFormat API? –  BalusC May 18 '10 at 12:46
true.. EL is the part im interested in. so ill rephrase the question... thanks for clarification. Although it would be nice to be able to use the tags from JSTL as well (e.g.: c:... and fmt:...) –  fasseg May 18 '10 at 12:56

1 Answer 1

up vote 4 down vote accepted

If you are using Jersey then it provides the ability to return a Viewable from the Resource which will process jsp by default.

Example Jersey Resource

public class PatientResource {
    @GET @Path("/{patientId}") @Produces(MediaType.TEXT_HTML)
    public Viewable view(@PathParam("patientId") int patientId) {
        return new Viewable("/patient.jsp", Integer.toString(patientId));

Example patient.jsp


NOTE: Jersey maps the object you pass to the Viewable as "it" in the jsp.

Once you have Jersey forwarding to the jsp then you just need to add an EL implementation to your application server or servlet container.

share|improve this answer
I know this was over a year ago, but could you clarify what you mean by adding an implementation? Do you mean add the dependency jars. If so, how would you use it after the import? –  Blaskovicz Oct 28 '11 at 1:00

Your Answer


