user2779544
user2779544

Reputation: 429

Access PageContext inside jsp declaration

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");

Upvotes: 4

Views: 1159

Answers (1)

MaVRoSCy
MaVRoSCy

Reputation: 17839

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");
    ......
}

Upvotes: 2

Related Questions