Ciao ragazzi ho appena letto i vostri post...
...in teoria è tutto chiaro ma in pratica...
...non mi funziona un' h!!...
...ho scaricato e completato un' esempio semplice semplice...
...una pagina html...
<HTML>
<HEAD>
<TITLE>
Servlet HTTP GET Example
</TITLE>
</HEAD>
<BODY>
<FORM
ACTION="http://localhost/studio/web-inf/classes/alias"
METHOD="GET">
Click the button to call a Servlet's (HelloWorld_Servlet) doGet() method from an HTML form..</P>
<INPUT TYPE="submit" VALUE='Submit (Method="GET")'>
</FORM>
<FORM METHOD="POST"
ACTION="http://localhost/studio/web-inf/classes/HelloWorld_Servlet">
Click the button to call a Servlet's (HelloWorld_Servlet) doPost() method from an HTML form.</P>
<INPUT TYPE="submit" VALUE='Submit (Method="POST")'>
</FORM>
</BODY>
</HTML>
la sua Servlet...
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
public class HelloWorld_Servlet extends HttpServlet {
public void init( ServletConfig config ) throws ServletException {
super.init( config );
//Do nothing for now.
}
public void destroy() {
super.destroy();
//Do nothing for now.
}
public void doGet( HttpServletRequest req, HttpServletResponse resp )
throws ServletException, IOException {
PrintWriter pw = resp.getWriter();
pw.println( "<html>" );
pw.println( "<body>" );
pw.println( " <h1>Hello World from a Servlet's doGet() </h1>" );
pw.println( "</body>" );
pw.println( "</html>" );
}
public void doPost( HttpServletRequest req, HttpServletResponse resp )
throws ServletException, IOException {
PrintWriter pw = resp.getWriter();
pw.println( "<html>" );
pw.println( "<body>" );
pw.println( " <h1>Hello World from a Servlet's doPost() </h1>" );
pw.println( "</body>" );
pw.println( "</html>" );
}
}
il file web.xml
<web-app>
<servlet>
<servlet-name>alias</servlet-name>
<servlet-class>HelloWorld_Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>alias</servlet-name>
<url-pattern>http://localhost/studio/web-inf/clas...oWorld_Servlet</url-pattern>
</servlet-mapping>
</web-app>
...secondo voi dove sbaglio???
...se avete voi un'esempio già testato...grazie mille!!