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

By default, where does Spring Boot expect views to be stored?

The Solution I found the answer via trial-and-error, which turned out rather annoying. I hope someone can correct me if this conclusion is wrong, but it appears that Spring Boot does not like the string WEB-INF. I renamed the WEB-INF directory to view and changed the application.properties to the following and the view loaded successfully. … 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

JSP debugging in IntelliJ IDEA

For JSP debugging in Intellij there are some configurations that must be in order. The fact that Intellij always allows you to add a breakpoint on a JSP line does not necessarily imply that you’ve configured JSP debugging. In the following I refer to Intellij 8 configuration, w.r.t. previous versions you will need to do … Read more

How to check a boolean condition in EL?

You can have a look at the EL (expression language) description here. Both your code are correct, but I prefer the second one, as comparing a boolean to true or false is redundant. For better readibility, you can also use the not operator: <c:if test=”${not theBooleanVariable}”>It’s false!</c:if>

Get windows username using JAVA or JSP [closed]

Getting the name of the user logged into your web application (which I think is what you want to do, based on your comments) entirely depends on how you have implemented authentication in your system. However, if your login mechanism adds this information, the username might be available in request.getRemoteUser() or request.getUserPrincipal(). But as mentioned, … Read more

Why are Bootstrap’s form elements rendered terribly with Struts2-Boostrap-Plugin?

Struts2 uses Themes to generate HTML from Tags: a different theme chosen, a different HTML in output. The default theme is XHTML, that generates <td>, <label> and other stuff around your elements. Usually, I recommend to use the simple theme, that generates almost no additional code, and that would make your code work as-is. Put … Read more

Struts Web Application: Reusable Validation Client-Side & Server-Side

Server side validation is mandatory : the request can come from a modified webpage, for example with rules altered with FireBug or any kind of DevTools. Or even easier, the request can be crafted by a malicious user, coming from a page (or a javascript block, or else) created ad-hoc, completely bypassing your page. Think … Read more

Unable to get Struts2 Hello World to work using Eclipse and Maven

If you follow the tutorial, which is linked to the page Struts 2 Hello World Example, and done everything till p. 7 then you should Run it as is written In Struts2, you can access the action class directly with a suffix of .action. http://localhost:8080/Struts2Example/User/Login.action If you tried to access application as http://localhost:8080/Struts2Example you will … Read more

Creating a json object in jsp and using it with JQuery

Here’s an example you may take a look at. Basically your JSP page might look like this: <%@page contentType=”text/html; charset=UTF-8″%> <%@page import=”org.json.simple.JSONObject”%> <% JSONObject json = new JSONObject(); json.put(“title”, “TITLE_TEST”); json.put(“link”, “LINK_TEST”); out.print(json); out.flush(); %> and on the client: $.ajax({ url : ‘search.jsp’, data : { search: ‘test’ }, dataType: ‘json’, success : function(json) { … Read more