4

One of my jsp has a function in declaration

<%!
public String performLogic(String state) throws Exception {

    String resposeXML = "";

    resposeXML = GetRequestViaXML(pageContext);

}
%>

This performLogic function need to call a GetRequestViaXML function by passing pagecontext as parameter,So this pagecontext will be used to get all attributes which are set previously in jsp's .

I cannot modify parameters of performlogic nor GetRequestViaXML.

Is it is possible to get the page context inside declaration part of jsp like

pageContext.setAttribute("AppName","IVR");
pageContext.setAttribute("TransactionName","Billing");
user2779544
  • 429
  • 1
  • 8
  • 24
  • 1
    You should look at the Servlet that is created from your JSP. If you are using Tomcat, then look in Tomcat's work folder. You will see that your performLogic method is separate method from jspService method which is where pageContext is declared. – rickz May 07 '15 at 14:24

1 Answers1

2

You can access pageContext Object inside your declaration only if you pass it as parameter:

public String performLogic(String state, PageContext pc) throws Exception {
    pc.setAttribute("AppName","IVR");
    ......
}
MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125