JS files not specified in the application

I have a jsp page inside which I call my xhtml page. Am maps xhtml to facesServlet and activates the entire resource servlet, so it displays all js and css files perfectly if I click on the xhtml page.

If I got to the jsp page, then these files are not mentioned, firebug throws all kinds of js errors.

To get around, I added the js and css files to the web folder and included them and tried them, including in the xhtml and also on the jsp page, but they are not referenced, and for now, if I directly click on the xhmtl page , then downloading files works fine, but if I go and hit the jsp page, I end up with js errors, is there any other way to get the js file.

This is how I link to my js files

 <%@ include file="/common/taglibs.inc" %> <html> <head> <link rel="stylesheet" href="/css/Main.css" type="text/css"> <link rel="stylesheet" href="/css/Admin.css" type="text/css"> <link rel="stylesheet" href="/css/Home.css" type="text/css"> <script type="text/javascript" src="/js/icefaces/ace-jquery.js"/> <script type="text/javascript" src="/js/icefaces/ace-components.js"/> <script type="text/javascript" src="/js/icefaces/icepush.js"/> <script type="text/javascript" src="/js/icefaces/bridge.js"/> <script type="text/javascript" src="/js/icefaces/compat.js"/> <script type="text/javascript" src="/js/icefaces/fileEntry.js"/> <script type="text/javascript" src="/js/icefaces/jsf.js"/> <script type="text/javascript" src="/js/icefaces/icefaces-compat.js"/> <!-- BEGIN SCRIPT TO OPEN RIGHT NOW HELP POPUP, THIS SCRIPT INCLUDES THE FUNCTION OPENRN--> < %@ include file="/js/popupRightNow.inc" %> <!-- END SCRIPT TO OPEN RIGHT NOW HELP POPUP, THIS SCRIPT INCLUDES THE FUNCTION OPENRN--> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> </head> <body> <jsp:include page="/navigation/TopNav.jsp" flush="true"/> <jsp:include page="/trade_entry/UploadBlotter.xhtml"/> <!--BEGIN BOTTOM NAV --> <jsp:include page="/navigation/BottomNav.jsp" flush="true"/> <!--END BOTTOM NAV --> </body> </html> 

Any thoughts, suggestions?

Update:

I have a requirement to create new pages using jsf2 , and I created an xhtml page, but I want to get header and footer application themes and those defined in jsp , now I tried searching by integrating jsp into xhtml , but it was rightly suggested that this is not must be done.

Tried How to enable JSP page on Facelets page? but this did not work as my tags were not recognized and finally tried to create jsp and included in it an xhtml page that seemed to work, but not 100%.

So, since it stands right now, if I hit the xhtml page directly, then it works, but if I click on the jsp page with header/footer , then icefaces or say jsf stuffs is not working 100% hope I can clarify what what I'm trying to achieve.

Update 2

The js file from javax.faces.resources links to the xhtml page on the page, but does not link to the jsp page.

0
source share
1 answer

This is the web browser that downloaded these JS / CSS files. This is not a server that has to load / enable these JS / CSS files.

So, the path you specified in the src and href attributes is allowed relative to the current request URL, as you see in the address bar of the browser. They are not permitted regarding the location of the JSP file in the public webcontent.

So, if you have a context path in the request URL, for example:

http: // localhost: 8080 / somecontextpath / page.jsp

then, for example, your <link href="/css/Main.css"> will be loaded by your web browser at the following URL

http: // localhost: 8080 / css / Main.css

although actually it was

http: // localhost: 8080 / somecontextpath / css / Main.css

Correct it.

 <link rel="stylesheet" href="${pageContext.request.contextPath}/css/Main.css" type="text/css"> 

Or if you use Facelets

 <link rel="stylesheet" href="#{request.contextPath}/css/Main.css" type="text/css"> 

Or if you use JSF 2 <h:outputStylesheet> (and the <h:outputScript> components)

 <h:outputStylesheet name="css/Main.css" /> 

(and put the /css and /js folders in the /resources subfolder of the public webcontent)


By the way, the following line makes absolutely no sense:

 <jsp:include page="/trade_entry/UploadBlotter.xhtml"/> 

Here you mix viewing technologies. You cannot include it in another. Facelets is the successor to JSP. Use one or the other. You can mix them in 1 webapp, but not in 1 mode.

+2
source

Source: https://habr.com/ru/post/914362/


All Articles