Allora,
forse non mi sono spiegato bene, io ho già Eclipse e GlassFish installati e configurati (cioè ho fatto proprio scaricare GlassFish ad Eclipse...posso runnarlo e se vado in Firefox e faccio 127.0.0.1:4848 mi si apre la pagina di configurazione di GlassFish...quindi c'è...) ma non riesco a far runnare la mia servlet di esempio...
Io ho fatto così:
1) Ho creato un nuovo Dynamic Web Project
2) Ho creato una servlet chiamata Esempio contenente il seguente codice banalissimo
codice:
/* CODICE DEL FILE Esempio.java */ import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Esempio extends HttpServlet {
static final long serialVersionUID = 33;
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Io sono un titolo!</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
out.println("<h1>Questa è una prova!</h1>");
out.println("</body>");
out.println("</html>");
}
}
/* FINE CODICE DEL FILE Esempio.java */
3) Vado nella view Server di Eclipse e c'è il mio simpatico GlassFish messo in stopped, premo il tastino verde (start the server) e quello si runna ed infatti mi dà il seguente messaggino di conferma:
codice:
Name of the domain started: [domain1] and
its location: [/home/andrea/GlassFish-Prelude/glassfishv3-prelude/glassfish/domains/domain1].
Admin port for the domain: [4848].
4) Ora mi metto sulla mia classe Esempio e provo a farla eseguire clickando sul tastino verde che dice: "Run Esempio.java" ma non succede nulla...se vado nella view markers mi segna i seguenti problemi:
codice:
Description Resource Path Location Type
HttpServlet cannot be resolved to a type Esempio.java /test/src line 5 Java Problem
HttpServletRequest cannot be resolved to a type Esempio.java /test/src line 9 Java Problem
HttpServletResponse cannot be resolved to a type Esempio.java /test/src line 10 Java Problem
ServletException cannot be resolved to a type Esempio.java /test/src line 11 Java Problem
The import javax.servlet cannot be resolved Esempio.java /test/src line 2 Java Problem
The import javax.servlet cannot be resolved Esempio.java /test/src line 3 Java Problem
Perchè ?!?! che significa ?!? l'esempio è banalissimo e dovrebbe essere corretto...mi sai aiutare?
Grazie
Andrea