Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Problems with Application context


Message #1 by "Mickler, Tosh" <TMICKLER@l...> on Tue, 20 Feb 2001 12:24:52 -0800
Hi All,
 
I am having a problem with accessing an instance of a bean class that was
instantiated at the application scope. 
 
I instantiated the bean by:
<jsp:useBean id="App" scope="application" class="WebSAR.AppVars" />
 
I have a method that is local to the page:
<%! public String getRandomFileName(HttpSession mySession, ServletContext
myApplication) {
    String rndFName = new String();    
    String dateString = new String();
    Calendar d = new GregorianCalendar();
    dateString = String.valueOf(d.get(d.MONTH)) +
String.valueOf(d.get(d.DAY_OF_MONTH)) + String.valueOf(d.get(d.YEAR));
    int randomValue = (int)((Math.random() * 10000) % 999); 
    
    rndFName = myApplication.App.getApplicationSARDirAbs() + "\\" +
String.valueOf(randomValue) + (String)mySession.getAttribute("UserName") +
dateString + ".sar";
    return rndFName;
}
 
I call the method from within the JSP:
<%
out.println(getRandomFileName(session,application));
%>
 
Now, the error:
[20/Feb/2001:15:15:42] info (   95): JSP: JSP1x compiler threw exception
org.apache.jasper.JasperException: Unable to compile class for
JSPd:\Netscape\Server4\https-mickler\config\..\ClassCache\_jsps\_CNPS\_submi
t_jsp.java:36: No variable App defined in interface
javax.servlet.ServletContext.
            rndFName = myApplication.App.getApplicationSARDirAbs() + "\\" +
String.valueOf(randomValue) + (String)mySession.getAttribute("UserName") +
dateString + ".sar";
                                    ^
1 error
 
I want to know how to get at the methods of the instance App of the AppVars
class.  Does anybody know how?
 
Any help would be much appreciated!
 
Tosh
 
 

  Return to Index