我有一個servlet,我想從它向一個jsp文件發送數據:Servlet的不發送對JSP頁面屬性
String errmsg = "Services not available!";
request.setAttribute("errmsg",errmsg);
request.getRequestDispatcher("/WEB-INF/web/csrCustomerLists/custListDetails.jsp").forward(request, response);
可悲的是,該屬性沒有在文件中設置,我在接受空JSP。我已經嘗試了兩種方式:
<div> <% String message = (String) request.getAttribute("errmsg");</div>
out.println("Servlet communicated message to JSP: "+ message);%>
<div>Try no:2<c:out value="${errmsg}"/></div>
我檢查與螢火蟲,我得到這個:提前
Servlet communicated message to JSP: null
感謝。
更新: 我設法畢竟一個錯誤:
java.lang.IllegalStateException:隱變量[javax.portlet.response]不是在請求上下文中可用。
你用什麼URL查看值?它是servlet URL還是JSP URL? – Masudul
我使用JSP URL來查看值 –
那麼,有沒有可能取代/包裝原始請求的過濾器?你可以調試它並記錄兩個地方的請求實例的哈希碼,並檢查它們是否引用同一個對象。 – Merlin