Performing user authentication in Java EE / JSF using j_security_check

I suppose you want form based authentication using deployment descriptors and j_security_check. You can also do this in JSF by just using the same predefinied field names j_username and j_password as demonstrated in the tutorial. E.g. <form action=”j_security_check” method=”post”> <h:outputLabel for=”j_username” value=”Username” /> <h:inputText id=”j_username” /> <br /> <h:outputLabel for=”j_password” value=”Password” /> <h:inputSecret id=”j_password” /> … Read more

Java / Jakarta EE web development, where do I start and what skills do I need? [closed]

(Updated Apr 2021) First of all, “Java EE” has since Sep 2019 been renamed to “Jakarta EE“, starting with version 8. Historically, there was also the term “J2EE” which covered versions 1.2 until 1.4. The “Java EE” covered versions 5 until 8. See also Java Platform, Enterprise Edition, History on Wikipedia. What exactly do I … Read more

What exactly is Java EE?

(Updated Feb 2022) First of all, “Java EE” has since Sep 2019 been renamed to “Jakarta EE“, starting with version 8. Historically, there was also the term “J2EE” which covered versions 1.2 until 1.4. The term “Java EE” covered versions 5 until 8. See also Jakarta EE, History on Wikipedia. Is Jakarta EE just a … Read more

How to install JDBC driver in Eclipse web project without facing java.lang.ClassNotFoundexception

As for every “3rd-party” library in flavor of a JAR file which is to be used by the webapp, just copy/drop the physical JAR file in webapp’s /WEB-INF/lib. It will then be available in webapp’s default classpath. Also, Eclipse is smart enough to notice that. No need to hassle with buildpath. However, make sure to … Read more

Simplest way to serve static data from outside the application server in a Java web application

I’ve seen some suggestions like having the image directory being a symbolic link pointing to a directory outside the web container, but will this approach work both on Windows and *nix environments? If you adhere the *nix filesystem path rules (i.e. you use exclusively forward slashes as in /path/to/files), then it will work on Windows … Read more

JSF Controller, Service and DAO

Is this the correct way of doing things? Apart from performing business logic the inefficient way in a managed bean getter method, and using a too broad managed bean scope, it looks okay. If you move the service call from the getter method to a @PostConstruct method and use either @RequestScoped or @ViewScoped instead of … Read more

Where to place and how to read configuration resource files in servlet based application?

It’s your choice. There are basically three ways in a Java web application archive (WAR): 1. Put it in classpath So that you can load it by ClassLoader#getResourceAsStream() with a classpath-relative path: ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream(“foo.properties”); // … Properties properties = new Properties(); properties.load(input); Here foo.properties is supposed to be placed … Read more

How can I upload files to a server using JSP/Servlet?

Introduction To browse and select a file for upload you need a HTML <input type=”file”> field in the form. As stated in the HTML specification you have to use the POST method and the enctype attribute of the form has to be set to “multipart/form-data”. <form action=”upload” method=”post” enctype=”multipart/form-data”> <input type=”text” name=”description” /> <input type=”file” … Read more