public class SampleServlet extends HttpServlet {
public void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException,IOException {
ServletContext context = this.getServletContext();
context.setAttribute("name","なまえ");
response.setContentType("text/html;charset=Windows-31J");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("name=" + context.getAttribute("name"));
out.println("</body></html>");
}
}
|