Add global Jsp to enable tomcat-6 in Liferay

I have a Jsp that should be dynamically included in the whole project when the user opens any jsp. That is, when the user opens jsp, my jsp should automatically turn on.

I wrote this in web.xml in Tomcat

<jsp-property-group> <url-pattern>/webapps/ROOT/html/*.jsp</url-pattern> <url-pattern>*.jspf</url-pattern> <el-ignored>false</el-ignored> <scripting-invalid>false</scripting-invalid> <is-xml>false</is-xml> <include-prelude>/WEB-INF/jsp/tracker.jsp</include-prelude> <!-- <include-coda>/template/coda.jspf</include-coda> --> </jsp-property-group> 

I saved my jsp in tomcat under WEB-INF / jsp / and I want to include it in every file as it contains code that keeps track of the log for the user.

Or any other way to do this.

Thanks.

+4
source share
2 answers

There are two ways to do this.

An easy way is to include your JSP in the theme. When your theme is applied to your project and when the theme is displayed, any pages in your project will display this included JSP.

Sample code below. This should be placed in the vm file (navigation.vm).

$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")

Here, the JSP folder is placed directly on the subject of war.

Another (tedious) way is to include this JSP on every JSP page that you want to include.

Use the <jsp:include> element for this.

Some links

Ref1 Ref2

+1
source

There is another way to enable your JSP for the entire portal and, i.e. docking station.

You can create a hook and enable jsp in /html/portlet/dockbar/view.jsp using <jsp:include /> or <liferay-util:include /> or a simple <%@ include file="" /> (that was would be static).

 <jsp:include page="/jsp/yourJSPPageToBeIncluded.jsp" /> 

OR

 <liferay-util:include page="/jsp/yourJSPPageToBeIncluded.jsp" /> 

OR

 <%@ include file="/jsp/yourJSPPageToBeIncluded.jsp" /> 

Note: the path may differ depending on where you will place the JSP.

Why do I choose the dockbar, because it is present on all pages of the liferay portal. This will not work if you open a pop-up pop-up window or a pop-up window with a "view and view" function or other custom pop-ups, since the dock is not in the pop-up window. For use in pop-ups, you need to redefine portal_pop_up.vm in your custom theme and write code, as suggested by @VikasV

 $theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp") 
+4
source

All Articles