• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Servlet not compiling

 
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;

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 (), getAttribute(). If I use getValue() my program compiles. I do not know where I am wrong. I am using JDK1.4 beta version, JBoss3.2.3 which supports latest Servlet specification.
Please help.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sure sounds like a version conflict to me - did you every have a much older servlet library installed on that system?

Bill
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic