Why Facelets is preferred over JSP as the view definition language from JSF 2.0 onwards?

True, JSP has some templating capabilities, but the biggest disadvantage of using JSP in JSF is that JSP writes to the response as soon as it encounters template text content, while JSF would like to do some pre/post processing with it. In JSF 1.0/1.1 the following JSF code <h:outputText value=”first”/> second <h:outputText value=”third”/> fourth would … Read more

How to output HTML from JSP block?

You can’t use the ‘out’ variable (nor any of the other “predeclared” scriptlet variables) inside directives. The JSP page gets translated by your webserver into a Java servlet. Inside tomcats, for instance, everything inside scriptlets (which start “<%”), along with all the static HTML, gets translated into one giant Java method which writes your page, … Read more

How to create user-friendly and seo-friendly urls in jsf?

If this is intended as an improvement of an existing application, then you basically need a Filter which detects “dirty” and “friendly” URLs. When it detects a “dirty” URL, then it should redirect the request to a “friendly” URL by HttpServletResponse#sendRedirect(). When it detects a “friendly” URL, then it should forward the request to the … Read more

How to iterate HashMap using JSTL forEach loop? [duplicate]

Try this, suppose my MAP is :- Map<String, String> countryList = new HashMap<String, String>(); countryList.put(“United States”, “Washington DC”); countryList.put(“India”, “Delhi”); countryList.put(“Germany”, “Berlin”); countryList.put(“France”, “Paris”); countryList.put(“Italy”, “Rome”); request.setAttribute(“capitalList”, countryList); So in JSP , <c:forEach var=”country” items=”${capitalList}”> Country: ${country.key} – Capital: ${country.value} </c:forEach> Hope this helps !

Get request URL in JSP which is forwarded by Servlet

If you use RequestDispatcher.forward() to route the request from controller to the view, then request URI is exposed as a request attribute named javax.servlet.forward.request_uri. So, you can use request.getAttribute(“javax.servlet.forward.request_uri”) or ${requestScope[‘javax.servlet.forward.request_uri’]}

How to install JSTL? The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved [duplicate]

It look like that you’re using JSTL 1.0 with taglib URIs of 1.1/1.2. You have JSTL in different versions: 1.0: exist of two JAR files jstl.jar and standard.jar. Taglib URI is has no /jsp in path and library name is suffixed with _rt like http://java.sun.com/jstl/core_rt. Came along and requires at minimum Servlet 2.3 / JSP … Read more

java.lang.RuntimeException Cannot find FacesContext

java.lang.RuntimeException: Cannot find FacesContext Thus, the JSF <f:xxx> and <h:xxx> tags are complaining that FacesContext cannot be found. The FacesServlet is the one responsible for creating the faces context. The faces servlet is invoked when the request URL matches its URL pattern, which is in your particular case *.jsf. So, when you open the index.jsp … Read more

The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Get rid of any servletcontainer-specific libraries such as jsp-api.jar in your /WEB-INF/lib folder. This exception indicates that you’ve put servletcontainer-specific libraries of a container which supports only Servlet 2.4 / JSP 2.0 or older in there (the getJspApplicationContext() method was introduced in Servlet 2.5 / JSP 2.1). This is a major mistake. Those libraries don’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)