The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20131106

[SOLVED] java ee xhtml, how to hide jsf tags in source code

today's task at work was to find out how to hide xhtml tag code in jsf pages, i.e. when a user attempts "view > source code", we don't want them to see the non-rendered jsf tags. i searched a lot, using the following search phrases:
jsf hide source code
primefaces hide source code
jsf don't show source code
jee hide jsf source code
jee web.xml hide jsf source
hide xhtml source
jsf disable viewing xhtml source

but surprisingly found no concrete answer as to how to solve this, but after much trial and error, i've finally figured it out.

put this code in your web.xml:

<servlet>
    <servlet-name>facesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    <url-pattern>*.xhtml</url-pattern>

    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>



No comments:

Post a Comment