The question comes up quite frequently on various forums, stackoverflow, etc. on JSTL and JSF. I don't want to beat a dead horse so I will leave it to the authors of these posts to explain the differences.
If you have any other good posts, please let me know and I will aggregate them here.
Friday, February 01, 2013
Thursday, January 24, 2013
JSF 2.x Tip of the Day: AJAX Redirection from @WebFilter (Filter)
I was working on an application where I needed to have it redirect to a login page when certain conditions exist in the application, e.g. session timeout, etc. A
The first thing is to determine if the request is a
Note: This is being intercepted in a Filter so I don't have access to the FacesContext. Here is a partial code snippet of how to send the redirect. You would need to set the variable
ViewExpiredException
custom exception handler (available in JSF 2.0) can handle this case, but I had a need for another type of "Session" object to be monitored to determine if I should redirect based on its status. The other object was stored in the HttpSession
object as an attribute so I decided to handle it with a Filter
(@WebFilter
).The first thing is to determine if the request is a
partial/ajax
request. If it is a normal post, we can handle it with a HttpResponse.sendRedirect(String location)
mechanism. If it is AJAX, we need to handle it in a completely different manner.
Once I determined that the request was AJAX, I needed to be able to pass the appropriate response back to the JSF page in a format that it could understand. A great tip came from Jim Driscoll's blog: Redirecting from a JSF 2.0 Ajax Request which gave me the general syntax for what I needed to send back.
Note: This is being intercepted in a Filter so I don't have access to the FacesContext. Here is a partial code snippet of how to send the redirect. You would need to set the variable
TARGET
to go to the desired location.
Monday, January 14, 2013
GlassFish 3 Tip of the Day: Using JDK 7 with JSP Code
A question came up on the NetBeans J2EE Mailing List about using JDK 7 with GlassFish 3.1.2. Specifically, they were getting the error:
The fix is quite simple. You must include a
Please see the example below for a complete configuration.
The project will now compile and use JDK7.
org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP
PWC6197: An error occurred at line: 4 in the jsp file: /index.jspPWC6199: Generated servlet error:strings in switch are not supported in -source 1.5 (use -source 7 or higher to enable strings in switch)
The fix is quite simple. You must include a
glassfish-web.xml
file in your project, and set a couple of properties. compilerSourceVM
and compilerTargetVM
.Please see the example below for a complete configuration.
The project will now compile and use JDK7.
Subscribe to:
Posts
(
Atom
)
Popular Posts
-
Introduction This article is not another diatribe to tell you the importance of unit testing. I think we can all agree that it is important...
-
A friend of mine asked me if there was a list of reserved words in EL and JSF. He had previously looked for it, and after some Google search...
-
I saw a question posed on stackoverflow called Trouble with Primefaces 3.0.M2 SelectOneMenu Ajax behavior and I had just done an example a...
-
I was working on a couple of SSL based issues when I made a couple of observations. The default self-signed key generation in Java does not ...
-
This is an example on how to make a system call to the local operating system to execute external programs. This example was written to work...
-
We have been doing a lot of work lately with PrimeFaces. A common set of questions comes up about displaying <p:dialog/> boxes on a pa...
-
I was asked earlier today how to reset fields in a JSF application, if the validation fails. In his case, he had a Richfaces table which had...
-
Previously, I posted an example of how to use JSF 1.2 with form based authentication (j_security_check). In this example, I use JSF 2.x to...
-
Image by quasarkitten via Flickr The basics for creating a Maven archetype can be found in the Maven - Guide to Creating Archetypes . The ...
-
Abstract A common use case is to iterate over a collection of elements, and display them on a page. In the world of JSP, we would use a Ja...