1. 程式人生 > >如何從env-entry獲取引數?

如何從env-entry獲取引數?

4.從env-entry獲取:(視訊下載) (全部書籍)

馬克-to-win:用env-entry存放的引數,本個web應用中的任何servlet,jsp都可以獲得。和context-param相比,env-entry存放的引數不止為String型別。下面的comp是component的意思。

例:1.4.1

ServletHello1.java:
 

 

package com;

import java.io.IOException;
import java.io.InputStream;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ServletHello1 extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Context ctx;
        boolean isReady = false;

詳情請見:http://www.mark-to-win.com/index.html?content=Jsp/jspUrl.html&chapter=Jsp/jsp2_web.html#GetParamWithenv-entry