You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Adam Wiener <ad...@yahoo.com> on 2001/10/23 22:08:27 UTC
Newbie question: Has anyone had trouble compiling code containing HttpServletRequest.getRequestURL() ???
Hello,
I am currently running Tomcat 3.2.2 (I know, I've been meaning to
upgrade...) and I am using the default servlet.jar that comes with that
distribution. Whenever I try to compile the following code:
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
out.println(req.getRequestURL().toString());
}
I get a compilation error saying that the compiler cannot resolve the
getRequestURL method in the HttpServletRequest Interface.
However the following code compiles just fine:
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
out.println(req.getRequestURI());
}
am I missing something really obvious? All the documentation I can find
says the getRequestURL() method is valid... Anyone else have a similar
problem?
Thanks in advance,
Adam
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
RE: Newbie question: Has anyone had trouble compiling code containing HttpServletRequest.getRequestURL() ???
Posted by Greg Trasuk <st...@on.aibn.com>.
Hi Adam:
Somewhere in your compiler classpath, you've got an older servlet.jar, as
the getRequestURL() method arrived in Servlet Spec 2.2. It may take a
little hunting to find it, especially if you're using an IDE (I've run into
this problem with IBM VA-Java v3.5), but what you need to do is get your
compiler to compile using the servlet.jar that you will find in Tomcat's
/lib directory.
Good luck, don't get discouraged, it all eventually works pretty well...
Greg Trasuk, President
StratusCom Manufacturing Systems Inc. - We use information technology to
solve business problems on your plant floor.
http://stratuscom.ca
> -----Original Message-----
> From: Adam Wiener [mailto:adam_wiener@yahoo.com]
> Sent: Tuesday, October 23, 2001 4:08 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Newbie question: Has anyone had trouble compiling code
> containing HttpServletRequest.getRequestURL() ???
>
>
> Hello,
>
> I am currently running Tomcat 3.2.2 (I know, I've been meaning to
> upgrade...) and I am using the default servlet.jar that comes
> with that
> distribution. Whenever I try to compile the following code:
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
> res.setContentType("text/plain");
> PrintWriter out = res.getWriter();
> out.println(req.getRequestURL().toString());
> }
>
> I get a compilation error saying that the compiler cannot resolve the
> getRequestURL method in the HttpServletRequest Interface.
>
> However the following code compiles just fine:
>
> public void doPost(HttpServletRequest req, HttpServletResponse res)
> throws ServletException, IOException {
> res.setContentType("text/plain");
> PrintWriter out = res.getWriter();
> out.println(req.getRequestURI());
> }
>
> am I missing something really obvious? All the documentation
> I can find
> says the getRequestURL() method is valid... Anyone else have a similar
> problem?
>
> Thanks in advance,
> Adam
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>