JCgH4164838Gh792C124B5 commented on a change in pull request #520:
URL: https://github.com/apache/struts/pull/520#discussion_r776092905
##########
File path:
apps/rest-showcase/src/main/webapp/WEB-INF/content/orders-deleteConfirm.jsp
##########
@@ -27,8 +27,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Orders</title>
- <s:link href="${pageContext.request.contextPath}/css/bootstrap.min.css"
rel="stylesheet"></s:link>
- <s:link href="${pageContext.request.contextPath}/css/app.css"
rel="stylesheet"></s:link>
+ <!-- Using a standard HTML link tag with JSP EL to get the contextPath may
be simpler, but this is an equivalent for s:link -->
+ <s:set
var="pageContextPath"><%=((HttpServletRequest)request).getContextPath()%></s:set>
+ <s:link href="%{#pageContextPath}/css/bootstrap.min.css"
rel="stylesheet"></s:link>
Review comment:
Hi @lukaszlenart .
Thanks for the feedback and suggestion. :)
I think for the above s:link tag suggestion:
`<s:link href="%{#request.pageContext}/css/bootstrap.min.css"
rel="stylesheet"></s:link>`
you may have meant to suggest `contextPath` rather than `pageContext`, so
something like:
`<s:link href="%{#request.contextPath}/css/bootstrap.min.css"
rel="stylesheet"></s:link>` ?
Unfortunately, neither worked (nor did similar attempts to access the
`contextPath` via the value stack). I had tried various expressions to try and
get the information, but every attempt to get it from the value stack resulted
in an empty string.
Since the TLD does not allow for JSP EL usage either, the only solution I
could find on the JSP was to use a JSP expression. If there was an action
class to use in the example, we could make it request aware and implement a
getter (a more "Struts-ish" option).
So far, the PR's solution was the only one I could find that worked with
`s:link`. If there is a cleaner solution, please let me know and I will update
the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]