私はあなたがどのフレームワークも使うべきではないと思います。サーブレットを作成するだけです。なぜなら、フレームワークを使用していても、サーブレットが何であるかを理解する必要があるからです。これらのコードは、oracleのsiteのものです。doGetを修正して処理してください。または、doPostに変更することもできます。
import java.io.*;
// Packages for Servlets
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
/**
* Initializes the servlet. The method is called once, automatically, by the
* Java Web Server when it loads the servlet. The init() method should save
* ServletConfig object so that it can be returned by the getServletConfig()
* method.
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**
* Method to process HTTP GET requests. In this method a Simple HTML page
* displaying "Hello Oracle World" is built and presented to user.
* The parameters of doGet() method is
* 1) HttpServletRequest object, which encapsulates the data from the client
* 2) HttpServletResponse object, which encapsulates the response to the client
**/
public void doGet(HttpServletRequest p_req, HttpServletResponse p_res)
throws ServletException, IOException {
// Sets the content type of the response
p_res.setContentType("text/html");
// Create a ServletOutputStream to write the output
ServletOutputStream l_out = p_res.getOutputStream();
// Use ServletOutputStream to print the Hello Oracle World String in
// the HTML page
l_out.println("<HTML><HEAD><TITLE>Hello Oracle World</TITLE></HEAD>");
l_out.println("<BODY BGCOLOR =\"lightgrey\"><CENTER><BR><BR>");
l_out.println("<TABLE BORDER=4 BGCOLOR =\"blue\">");
l_out.println("<TR><TD align =\"center\" valign=\"center\" >");
l_out.println("<FONT face=\"Arial,helvetica\" color =red size=5>");
l_out.println(" Hello Oracle World </FONT></TD></TR></TABLE>");
l_out.println("</BODY></HTML>");
l_out.close(); // Close the ServletOutputStream
}
/**
* Override the getServletInfo() method which is supposed to return information
* about the Servlet, e.g. the servlet name, version, author and copyright
* notice. This is not required for the function of the HelloWorld servlet but
* can provide valuable information to the user of a servlet who sees the
* returned text in the administration tool of the Web Server.
**/
public String getServletInfo() {
return "Hello World servlet 1.0 by Reghu";
}
public void destroy() {
super.destroy();
}
}
Java WebアプリケーションやJava CMSに関する経験がない場合、なぜJavaでこれを行う必要がありますか? – Thilo