File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP using  getServletContext Error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "JSP using  getServletContext Error" Watch "JSP using  getServletContext Error" New topic
Author

JSP using getServletContext Error

MarkShane
Greenhorn

Joined: Jan 14, 2003
Posts: 5
Hi,
I'm trying to compile a jsp with the following line of code.
<%@ page language="java" import="java.io.*" %>
<%
String dbPath = getServletContext().getRealPath("/WEB-INF/myData.db");
%>
I keep getting the following error:-
method getServletContext() not found in class.
Any suggestions??.
vijith vayanippetta
Greenhorn

Joined: Nov 07, 2001
Posts: 3
Hi Mark,
If the real intention is to get the real path you can probably replace that code with this
<%
String realPath =
application.getRealPath("/WEB-INF/myData.db");
%>

application object represents the servletContext and is an implicit object available in jsp.
:-)
MarkShane
Greenhorn

Joined: Jan 14, 2003
Posts: 5
Thanks Vijith, it worked.
 
IntelliJ Java IDE
 
subject: JSP using getServletContext Error
 
Threads others viewed
Problem in Bea Weblogic 9.2
strange error during jsp compilation - pls help
Servlet and I/O
Duplicate error-page element
jsp:include when the html to be included is not present
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture