Help with Java servlet : getServletContext().
12/01/2018 12:08
I am newbie to Java, am trying to get a program working, and I haveimported the java packages below along with many other imports :
import javax.servlet.GenericServlet;....

xsltFile = new File(getServletContext().getRealPath(xslt/ +template)); if(!xsltFile.canRead()) { System.out.println(Error reading XSLT template file '+ xsltFile + '.); return 0; }
I get the following error, can anyone tell me what the problem is?
com
etodutilMyClass.java:243: cannot resolve symbolsymbol : method getServletContext ()location: class com.netod.util.MyClass xsltFile = new File(getServletContext().getRealPath(xslt/+ template));
thanks for any help

Source is Usenet: comp.lang.java.help
Sign in to add a comment

Answer score: 5
12/01/2018 12:08 - In article <d50h91$7ti$3@ichaos.ichaos-int>, Juha.Laiho@iki.fi enlightened us with...


Yeah, I realized after I posted that how stoopid that was.

I didn't have time to come correct myself.


Thanks. *embarrassed grin*

Source is Usenet: comp.lang.java.help
Sign in to add a comment

Answer score: 5
12/01/2018 12:08 - kaeli <tiny_one@NOSPAM.comcast.net> said:

What?
'this.foo()' is equivalent to 'foo()' - at least in all cases I can imagine(and please educate me if there are cases where this isn't so!). It willalways call method 'foo()' either on the current class, or on the closestsuperclass implementing the method.


There are cases where you might need an explicit 'this.' for referencinginstance variables (where you have a local variable of the same name,shadowing the instance variable), but for method calls, 'this.' is alwayssuperfluous.


Source is Usenet: comp.lang.java.help
Sign in to add a comment

Answer score: 5
12/01/2018 12:08 - In article <1114785464.432939.282130@o13g2000cwo.googlegroups.com>, vmswar2@yahoo.com enlightened us with...


What are you getting the servletContext FROM? ;)
someServlet.getServletContext()
Probably, depending on where this statement is running from, you wantthis.getServletContext()
You can call a method on nothing.
HTH

Source is Usenet: comp.lang.java.help
Sign in to add a comment

eDiscover
Helpforce eDiscover provides technical articles updated each dayHelpforce eDiscover RSS feed contains the latest technical articles in RSS
Click the logo to go back to the main page
Search eDiscover
  
Categories

Click an icon to go to that category

Helpforce eDiscover contains articles about Microsoft Windows Helpforce eDiscover contains articles about Apple products and MacOS Helpforce eDiscover contains articles about Linux and POSIX operating systems Helpforce eDiscover contains articles about Helpforce Helpforce has a large variety of technical information and articles for you to read Helpforce eDiscover contains articles about databases, MYSQL, SQL Server Oracle Helpforce eDiscover contains articles about Java, JVM and the JRE Helpforce eDiscover contains articles about the QNX operating system Helpforce eDiscover contains articles about Oracle Solaris and Open Solaris Helpforce eDiscover contains articles about RISC OS, Acorn and the BBC Micro Helpforce eDiscover contains articles about Amiga and AmigaOS

Type your comment into the box below