views:

100

answers:

1

Hi:

I have a Spring Controller where I am setting a session object with variables .

@RequestMapping("/index.html")
public String indexHandler(HttpSession session,
                           HttpServletRequest request,                                         
                           HttpServletResponse response){

          session = request.getSession(true);
          session.setAttribute("country","India");  
          session.setAttribute("url", getAuthURL());//getAuthURL returns a string

     return "tempJSP"; 
    //tempJSP is a JSP under webroot/jsps/ and this is configured in Dispatcher servlet
}

tempJSP.jsp

//My 2 taglibs are declared here one is core and other is format
<c:redirect url=<%(String)session.getAttribute("url")%> //Here it fails
+1  A: 

It fails because a <% %> doesn't print anything, the c:redirect tag isn't properly closed and possibly also because the value isn't enclosed in quotes. You rather want this:

<c:redirect url="<%= session.getAttribute("url") %>" />

Note that the cast is unnecessary.

However, using old fashioned scriptlets is discouraged since a decade. Rather use EL. It's then as easy and nice as:

<c:redirect url="${url}" />
BalusC
Yes you are right Balu. I should not be using scriptlets. Also there was another issue that was there which was selecting the right taglib.I changed it from "<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c'%>" to <%@ taglib uri='http://java.sun.com/jstl/core' prefix='c'%> That solved the issue
sv1
The right one is with `/jsp` in URI: `http://java.sun.com/jsp/jstl/core`.
BalusC