why jsp:include parameters not visible

不问归期 提交于 2019-12-05 12:16:16

To nail down the problem, try to debug/explore the entire map by printing ${param} in EL or HttpServletRequest#getParameterMap() in Java code. It must give insights about what the map really contains.

Right. I have had a similar problem that for the last hour or so and I have found a solution for my case.

I had index.jsp and tried to include news.jspf in it with text from a jsp param in the index.jsp It didn't work. It just showed the news.jspf EL as normal text.

I changed the included file name extension from .jspf to .jsp and it fixed the problem.

I'm using Eclipse, which may or may not be a factor.

Good luck

I've traced down the generated java source and it looks reasonable. Either one of two things are happening: org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode is messing up the varible name, or the classloader used resolves to JspRuntimeLibrary to some other instance than the one driving the web app.

// caller.jsp ....
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, 
  "callee.jsp" + (("callee.jsp").indexOf('?')>0? '&': '?') + 
  org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("justinVar",
  request.getCharacterEncoding())+ "=" +
  org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("primary", 
  request.getCharacterEncoding()), out, true
);

Looking inside Jasper's runtime, we find this gem. Its not clear that this is the problem, however the page being rendered is jsp:include from defaultParent.jsp, although jsp:params passed into the jsp:include from defaultParent don't seem to show up either.

  958           // FIXME - It is tempting to use request.getRequestDispatcher() to
  959           // resolve a relative path directly, but Catalina currently does not
  960           // take into account whether the caller is inside a RequestDispatcher
  961           // include or not.  Whether Catalina *should* take that into account
  962           // is a spec issue currently under review.  In the mean time,
  963           // replicate Jasper's previous behavior

This work in my Liferay portlet

ParamUtil.getString(PortalUtil.getOriginalServletRequest(request), "justinVar")

This issue can happen if the request is wrapped (i.e. HttpServletRequestWrapper), likely via a filter. See: jsp:param no longer sets parameters when original request is wrapped with a HttpServletRequestWrapper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!