Any clever ways of handling the context in a web app?

前端 未结 13 1489
一整个雨季
一整个雨季 2020-12-02 13:37

In Java, web apps are bundled in to WARs. By default, many servlet containers will use the WAR name as the context name for the application.

Thus myapp.war gets depl

13条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 13:45

    I by no means claim that the following is an elegant issue. In fact, in hindsight, I wouldn't recommend this issue given the (most likely) performance hit.

    Our web app's JSPs were strictly XML raw data. This raw data was then sent into an XSL (server-side) which applied the right CSS tags, and spit out the XHTML.

    We had a single template.xsl which would be inherited by the multiple XSL files that we had for different components of the website. Our paths were all defined in an XSL file called paths.xml:

    
    
        Account/
        css/
        servlet/
        icons/
        images/
        js/
    
    

    An internal link would be in the XML as follows:

    link to icons
    

    This would get processed by our XSL:

    
        
            
            
                
            
            
        
            
    
    

    $rootPath was passed onto each file with ${applicationScope.contextPath} The idea behind us using XML instead of just hard-coding it in a JSP/Java file was we didn't want to have to recompile.

    Again, the solution isn't a good one at all...but we did use it once!

    Edit: Actually, the complexity in our issue arose because we weren't able to use JSPs for our entire view. Why wouldn't someone just use ${applicationScope.contextPath} to retrieve the context path? It worked fine for us then.

提交回复
热议问题