หน้าเว็บ

วันอังคารที่ 25 ธันวาคม พ.ศ. 2555

read value tag <context-param> in web.xml : java

package com.blogspot.na5cent.jsflearning;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Redcrow
 */
@WebServlet(name = "ContextParam", urlPatterns = {"/contextParam"})
public class ContextParam extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        ServletContext servletContext = request.getServletContext();
        PrintWriter out = null;
        try {
            out = response.getWriter();
            out.print("javax.faces.PROJECT_STAGE => " + servletContext.getInitParameter("javax.faces.PROJECT_STAGE"));
            out.print("<bt/>");
            out.print("primefaces.THEME => " + servletContext.getInitParameter("primefaces.THEME"));
        } finally {
            if (out != null) {
                out.close();
            }
        }

    }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น