jsp - Calling Java Method from Servlet 2.5 -


i got little code snippet 1 of jsp files:

 <c:when test="${not empty param['filepath'] && not empty param['revision']}"> <c:out value="${sessionscope.filehelper.getcontentsforpath(param.filepath,param.revision)}" escapexml="false"/> </c:when> 

unfortunately have migrate servlet 2.5, using 3.0.

the problem is, el (expression language) not support calling methods in prior versions. asked me how accomplish same thing 2.5 compatible code.

the filehelper gets added sessionscope in different jsp file like:

<jsp:usebean id="filehelper"     class="de.mypackage.util.filehelper" scope="session" /> 

what tried was:

<%@ page import="de.mypackage.util.filehelper"%>  <c:when test="${not empty param['filepath'] && not empty param['revision']}"> <c:out value="<%=(filehelper)session.getattribute("filehelper").getcontentsforpath(request.getparameter("filepath"),(string)request.getparameter("revision"))%>" escapexml="false"/> </c:when> 

but doesn't work since writes:

the method getcontentsforpath(string, string) undefined type object.

any ideas ?

you have wrap cast session object within () use it's .getcontentsforpath() method. this:

((filehelper) session.getattribute("filehelper")).getcontentsforpath(...) 

Comments

Popular posts from this blog

c# - ItextSharp font color issue in ver 5.5.4+ -

jquery - Multiple issues with pushstate: history, loading, calling functions -

opengl es - Android GLES 2 draw line flicker and strange effects -