Compile Servlet error-import error
Jeg får følgende fejl når jeg prøver at compile (javac) nedenstående kode.import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* GuestJsp is a servlet controlling user
* interaction with the guest book.
*/
public class GuestJsp extends HttpServlet {
/**
* doGet handles GET requests
*/
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
{
// Save the message in the request for login.jsp
req.setAttribute("message", "Hello, world");
// get the application object
ServletContext app = getServletContext();
// select login.jsp as the template
RequestDispatcher disp;
disp = app.getRequestDispatcher("login.jsp");
// forward the request to the template
disp.forward(req, res);
}
}
ERROR:
import javax.servlet.*;
^
GuestJsp.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
GuestJsp.java:16: cannot resolve symbol
symbol : class HttpServletRequest
location: class GuestJsp
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
^
GuestJsp.java:16: cannot resolve symbol
symbol : class HttpServletResponse
location: class GuestJsp
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
^
GuestJsp.java:16: cannot resolve symbol
symbol : class ServletException
location: class GuestJsp
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException
^
GuestJsp.java:22: cannot resolve symbol
symbol : class ServletContext
location: class GuestJsp
ServletContext app = getServletContext();
^
GuestJsp.java:22: cannot resolve symbol
symbol : method getServletContext ()
location: class GuestJsp
ServletContext app = getServletContext();
^
GuestJsp.java:25: cannot resolve symbol
symbol : class RequestDispatcher
location: class GuestJsp
RequestDispatcher disp;
^
8 errors
Jeg giver snart op. Er der ikke nogen der ved hvad jeg gør forkert ???
Er det fordi jeg ikke refererer til en classpath eller hvad. Er ved at være godt træt at min Linux(Debian) distribution og alle de problemer jeg har med at kører diverse Java applikationer. Det ender snart med at jeg hopper tilbage til Windåsen, hvilke jeg nødigt vil, men jeg er ved at være træt af at bruge time på time med at få mit Java til at køre :-(
