如果只从特定的servlet重定向,我想对JSP执行操作,否则什么也不做。是否有可能?如果从servlet重定向,请对JSP执行操作
在我的JSP中定义了不同的错误。这个JSP调用一个servlet(contentType为application/pdf),它在新标签页中打开并搜索25秒的PDF,然后如果未找到PDF,则重定向到显示错误消息“找不到文件”的相同JSP。我想显示错误,如果从servlet调用,否则什么也不做。
JSP代码:
<%}else if(hPP!=null && hPP.get("errorcode")!=null && hPP.get("errorcode").toString().equalsIgnoreCase("Issue")){%>
<c:if test="${cameFromServlet}">
<div class="SplInputField">
<label class="FontBlod">Download fail</label>
</div>
</c:if>
servlet代码
if (content == null) {
request.setAttribute("cameFromServlet", true);
String redirectJspUrl = request.getParameter("homeRedirect");
String strReceiptPage =
redirectJspUrl.substring(0, redirectJspUrl.lastIndexOf("/")) +
"/GetQReceiptPage";
response.sendRedirect(strReceiptPage);
}
谢谢JSTL做(如果测试!= )的作品或有任何其他关键字不是? –
你可以使用!或者这个词不存在也存在关键字 – saml
它不起作用在我的case.Sry for基本Q,但我是编程世界的新手。我已经在Q上面添加了JSP/servlet代码 –