We help IT Professionals succeed at work.
Get Started

How to use getpageContext.RealPath  in a jsp program in Weblogic

dfn48
dfn48 asked
on
823 Views
Last Modified: 2012-05-12
The  following jsp program works well in tomcat but i get an error message in weblogic.  The

error that i get in Weblogic is as follows

doc_ss.jsp: 42:13: No method with this name could be found at this location.
String path=getServletContext().getRealPath(“/ns.txt”)
No method with this name could be found at this location,   getRealPath(java.lang.String) in type <error>
String path=getServletContext().getRealPath(“/ns.txt”).  Please tell me what is the correct syntax for Weblogic

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page language="java" import="java.io.* "%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<%

String textToTextArea = "";
String path=getServletContext().getRealPath("/ns.txt");
File file = new File(path);
FileReader in = new FileReader(file);
int c;
char ch;
while (( c= in.read()) != -1){
ch=(char)c;
textToTextArea += ch;
}
in.close();

    %>

</td>
</tr>
</table>
<H1>Notification(s):</H1>
    <FORM id="frmnotification" name="frmnotification" action="doc_ss.jsp" method="post">
           <textarea cols="300" rows="30" name="txtnotification" class="txtarea-style"><%=textToTextArea%></textarea>



    </FORM>
    </body>
</html>

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2007
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE