0

I have inherited an ancient codebase web application using Spring and JSPs. I've been charged with moving from Spring 3 to Spring 6.

Inside a tag is the following code:

str = ExpressionEvaluationUtils.evaluate("href", (String) str, this.pageContext).toString()

I did searches and it says that ExpressionEvaluationUtils is still available in Spring 6. If it is, I can't find it.

Did further digging and finally looked at the deprecation in the spring 3 libraries, which says use JSP 2.0's javax.servlet.jsp.el.ExpressionEvaluator. This appears to have been deprecated over the years as well and I can't find any trace of what to use in it's place.

I found Alternative of ExpressionEvaluationUtils in Spring 4 but this answer doesn't work under the current architecture.

Can anyone advise me how to replace this line of code?

4
  • Side note: In Spring 6, the package names for Servlet and JSP have changed from javax to jakarta. The recommended specification applied is Jakarta EE 10. When Jakarta EE 10 is used with Tomcat, it corresponds to Tomcat 10.1. Commented Apr 16 at 14:25
  • maybe: jakarta.el.ExpressionFactory Commented Apr 16 at 14:33
  • can you try stackoverflow.com/a/32438053/1811348 Commented Apr 16 at 14:36
  • @life888888 Yes, that's what it's looking like Commented Apr 16 at 14:36

1 Answer 1

0

So, based on a bunch of research, I've come up with the following code:

ExpressionFactory expressionFactory = ExpressionFactory.newInstance();
ValueExpression valueExpression = expressionFactory.createValueExpression(pageContext.getELContext(), str, String.class);
str = valueExpression.toString();

It will be a while before I can actually test it, so please speak up if this is a stupid thing to do.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.