• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP to EL conversion

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have this page thats filled with scriptlets that I'm trying to convert to EL. I have these scriptlets that I need to convert to EL:

<%@ page import="org.springframework.security.ui.AbstractProcessingFilter"%>
<%@ page import="org.springframework.security.ui.webapp.AuthenticationProcessingFilter"%>
<%@ page import="org.springframework.security.AuthenticationException"%>

<% if (session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY) != null) { %>
<font color="red">
Reason: <%= ((AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
</font>
<% } %>

Basically these are the import statements and following scriptlets

session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)

and

((AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage()

Can anyone help please?

For the bottom one, I have
${sessionScope.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY.message}

but it doesn't seem to work. I have no clue on how to deal with imports.


Thanks in advance
[ June 04, 2008: Message edited by: cin jang ]
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can lose the imports completely. They are not necessary.

You seem to understand that scriptlet expressions are replaced by EL expressions.

The Java if statement can be replaced with the JSLT <c:if> tag.
[ June 04, 2008: Message edited by: Bear Bibeault ]
 
cin jang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, thanks for the reply

I'm aware of the fact that I can use the core JSTL tags to do basic if-else and other things like iterations. I'm just not understanding how to convert

((AuthenticationException) session.getAttribute(AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage()

this statement into a corresponding EL expression
I have ${sessionScope.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY.message}

but it doesn't seem to work.

if anyone could provide a hand, that'd be great
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In

I have ${sessionScope.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY.message}

you are trying to access session attribute called AbstractProcessingFilter, but it is Spring Security class, which have constant SPRING_SECURITY_LAST_EXCEPTION_KEY, which contains name of exception attribute.

You can get name of this attribute here:Spring Security API.

You must write: ${sessionScope.SPRING_SECURITY_LAST_EXCEPTION.message} for exception message.
 
cin jang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about the late reply, but thanks so much for helping me out. I really appreciate it
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how will i change
String abc = (String) session.getAttribute("child");
to EL tag..
is this correct?
${sessionScope.child}
Is this correct? how to assign that to a string abc in JSP ...?
Thanks in advance
 
Amadeus mozart
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
got the answer...
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Amadeus mozart", please check your private messages for an important administrative matter.
reply
    Bookmark Topic Watch Topic
  • New Topic