• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to EL conversion

 
cin jang
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Intars Zilickis
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Sorry about the late reply, but thanks so much for helping me out. I really appreciate it
 
Amadeus mozart
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
got the answer...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Amadeus mozart", please check your private messages for an important administrative matter.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!