2012-12-10 3 views
0

'home.jsp'파일 또는 'error.jsp'파일 중 하나를 포함하려고합니다.동적으로 jsp 파일을 기본보기에 포함하십시오.

: 나는 일식에이 오류가

// 서블릿

... 
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
{ 

      // api access 
     Api apix = new Api(new ApiRequest(-1)); 

     // post params 
     String email = request.getParameter("email"); 
     String password = request.getParameter("password"); 

     // exists? 
     User user = apix.userManager.authenticate(email, password); 

     // template 
     String address = "/main.jsp"; 

       // variable content 
     String content_page = "/WEB-INF/user/home.jsp"; 


     if (user == null) 
     { 
      content_page = "/error.jsp"; 
     } 

     request.setAttribute("content_page", content_page); 
     RequestDispatcher dispatcher = request.getRequestDispatcher(address); 

     dispatcher.forward(request, response); 


} 

// main.jsp

<head> 
    <jsp:include page="/head_includes.jsp"/> 
</head> 

<body> 

    <% 
     String content_page = request.getParameter("content_page"); 

     if (content_page == null) 
     { 
      content_page = "/error.html"; 
     } 

    %> 

      <!-- I get an error here --> 
      **<jsp:include page="<%= content_page %>">** 
</body> 

: 이것은 내 서블릿 파일 내 템플릿입니다

org.apache.jasper.JasperException: /main.jsp (line: 29, column: 1) Expecting "jsp:param" standard action with "name" and "value" attributes 

답변

0

오류가 분명합니다.

main.jsp

jsp:param 또는 querystring main.jsp?name=value

를 사용

중 하나를 통과해야 매개 변수를 기대하고있다

관련 문제