Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is simplified version of DynamicContentAction.java</p> <pre><code>public class DynamicContentAction extends ActionSupport implements ServletRequestAware, ServletContextAware { private HttpServletRequest request; private ServletContext servletContext; private ResourceSelectorService resourceSelectorService; private String f = null; public String execute() { if ( f != null ) { HashMap&lt;String, Object&gt; resolvedURI = resourceSelectorService.resolveURI(f); if ( resolvedURI.get("ERROR").equals(true) ) { //Generating nice 404 error page content } else { //Generating Content //and put it on request object as: //request.setAttribute("attrName", resourceContent); } } else { //Generating nice 404 error page content } request = null; servletContext = null; f = null; return "index"; } @Override public void setServletRequest(HttpServletRequest request) { this.request = request; } @Override public void setServletContext(ServletContext servletContext) { this.servletContext = servletContext; } public void setF(String f) { this.f = f; } public String getF() { return f; } } </code></pre> <p>as I'm writing this post, I have came to the knowledge that this class is NOT thread-safe. Is it? So I've changed it a little bit as follow:</p> <p>Here is newer version of DynamicContentAction.java</p> <pre><code>public class DynamicContentAction extends ActionSupport { private ResourceSelectorService resourceSelectorService; private String f = null; public String execute() { if ( f != null ) { final HttpServletRequest request = ServletActionContext.getRequest(); final ServletContext servletContext = ServletActionContext.getServletContext(); HashMap&lt;String, Object&gt; resolvedURI = resourceSelectorService.resolveURI(f); if ( resolvedURI.get("ERROR").equals(true) ) { //Generating nice 404 error page content } else { //Generating Content //and put it on request object as: //request.setAttribute("attrName", resourceContent); } f = null; } else { //Generating nice 404 error page content } return "index"; } public void setF(String f) { this.f = f; } public String getF() { return f; } } </code></pre> <p>and the Null thing problem is almost gone, but there is still conflict with the generated content. For example if user try to open:<br /><br /> http:// www.domain.com/A<br /> http:// www.domain.com/B<br /> http:// www.domain.com/C<br /> http:// www.domain.com/D<br /> http:// www.domain.com/E<br /><br /> simultaneously, all of the pages will be rendered in browser, but the content of A is shown in A and B, C is correct, and there is a very good chance that the content of D and E are incorrect too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload