• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

unable to compile... urgent!

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am unable to compile my servlet. if i do not use requestURL() then it compiles. i have set my classpath as
.;D:\java\core\packages;D:\oracle\ora81\jdbc\lib\classes111.zip;d:\JSDK\lib\jsdk.jar;d:\j2ee1.3.1\lib\j2ee.jar;D:\jakarta-tomcat\lib\servlet.jar;D:\jboss-3.2.3\server\default\lib\javax.servlet.jar;import javax.servlet.*;

I am getting two errors when i compile this servlet:

D:\jboss-3.2.3\server\default\deploy\cpnm.war\WEB-INF\classes>javac TokenServlet.java
TokenServlet.java:22: cannot resolve symbol
symbol : method getRequestURL ()
location: interface javax.servlet.http.HttpServletRequest
String requestURLSame =req.getRequestURL().toString() + "?token=" +tokenID;
^
TokenServlet.java:23: cannot resolve symbol
symbol : method getRequestURL ()
location: interface javax.servlet.http.HttpServletRequest
String requestURLNew =req.getRequestURL().toString();
^
2 errors

import javax.servlet.http.*;
import java.util.*;
import java.io.*;

public class TokenServlet extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,

IOException {
String tokenID=req.getParameter("tokenID");
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<html><head><title>Tokens</title></head><body> ");

if(tokenID==null) {
Random rand=new Random();
tokenID=Long.toString(rand.nextLong());
out.println("<p> Welcome. A new token "+tokenID + " is now established</p>");
}
else {
out.println("<p> Welcome back. Your token is " +tokenID + ".</p>");
}

String requestURLSame =req.getRequestURL().toString() + "?token=" +tokenID;
String requestURLNew =req.getRequestURL().toString();

out.println("<p> Click <a href=" + requestURLSame + "> here</a> again to cont. browsing with

same identity.</p>");
out.println("<p> Otherwise, click <a href=" + requestURLNew + "></a> again to start with new

identity.</p>");
out.close();

}
}

Facing the same problem when I try to use getServletContextName ()
Please help.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic