How to use a java class in a taglib scriptlet?

604 Views Asked by At

I am trying to pass an exception string from a java class into a taglib. I take the exception from the request and pass that into a taglib that generates a div on a page with the error text. However i am getting an error saying "e cannot be resolved" The following is my code.

<% MyException e = (MyException) request.getAttribute(MyFields.EXCEPTION);
   if (e != null) { 
        String warningLevel = "none";
        if(e.getEndUserMessage().contains("warningLevel")){
            warningLevel = e.getEndUserMessage().substring(e.getEndUserMessage().indexOf("warningLevel=\"") + 14, e.getEndUserMessage().indexOf("\""));
        }
%>

<e:errorcontainer warningLevel="<%=warningLevel %>">
    <e:error propertyFile="${SSOFields.ERROR_PROPERTIES}"
            alertProperty="<%=e.getEndUserMessage()%>">  //This line is where e cannot be resolved
    </e:error>
</e:errorcontainer>
<%
   }
%>

I am still learning things about jsp's, so any help would be amazing. Thank you in advance.

2

There are 2 best solutions below

0
On

Maybe your error isn't about the variable 'e', but taglib 'e'? For example, you didn't declare it on top of the JSP file?

2
On

You've got two potential "e" things that could not be resolved - the exception and the namespace of your taglib. You may have bugs importing the taglib into your page or application namespace, which you can quickly eliminate by renaming your exception variable.