Cyndi Vasquez sent me this title a while back. I have been so bogged down that I finally got a chance to look at it. Thanks Murach... this is a good book.
The book is written in a style that many will either love, or hate. I personally am on the former. The pages on the left side are an explanation of the technical matter, and the right side are examples. The book is designed to guide you from front to back on an adventure into programming. Along the safari, I assure you will be pleased. The quarry is knowledge and this book is the tool to capture it.
The books is divided into five sections which will take you from absolute beginner to accomplished Servlet and JSP aficionado. It will even teach you a little about databases, and JSF along the way. There are two appendices that will show you how to set up your computer either Mac, or PC before you get started on your journey.
One of the thrills about this book is the use of NetBeans. I believe that NetBeans is the easiest tool for developing web based applications using Servlets and JSP. It also is my preferred tool for Java development in general. The book not only teaches you about the essentials of the title technologies, but helps you gain an in-depth knowledge of a valuable IDE that you can bank your career on.
Section one covers the basics of the technology and the MVC pattern. This is followed by a crash course on HTML, CSS, and web technologies based on Java. The 8th chapter on EL is a great reference for how to use this important technology in your web applications.
Section three covers essential database skills to get you started with web development. These skills are the bare minimum to get started, but are complete for the purpose of this book. Keep in mind, these are the basics.
Section four is the meat of the book. This covers the advanced Servlet and JSP skills. It also covers some additional technologies like JSF. My favorite parts of this section are chapters 18, 19, and 20. The HTTP Request and Response skills are something every developer should strive to make sure they understand. Chapter 19 covers listeners which are truly your friends. Chapter 20 covers another often misused, abused, and otherwise fantastic technology. The filter can make your life as a web developer a great pleasure, or a rabbit hole in which you feel like Alice in Wonderland.
The final concluding section five puts all of the pieces together in a Music Store website. The Music Store website uses most of the technologies covered, and takes the learner to the next level with clear and concise directions.
Overall this is a great book for anyone interested in learning about Servlet and JSP technology. Please keep in mind that all Java web technologies are based on the Servlet foundation. JSF is nothing more than a veneer on top of this technology as an example.
Showing posts with label development. Show all posts
Showing posts with label development. Show all posts
Sunday, September 06, 2015
Monday, June 24, 2013
GlassFish Tip of the Day: HttpOnly
This is just a quick tip for those who are configuring HttpOnly on GlassFish. To enable it, you simply add the following to your web.xml.
The default on GlassFish is to have it enabled anyway, and you must explicitly disable it.
UPDATE:
The issue I had was testing it. When I deployed my application to localhost I did not see any of the cookies being marked as HttpOnly. I was using Chrome and auto-deploying my application, before I turned on the developer tools. The initial request contained the header marking it as HttpOnly. You can confirm it by easily using JSF and the method below. Simply invalidate the session while using the developer tools and examine the response returned.
I got a response header like the one below.
The default on GlassFish is to have it enabled anyway, and you must explicitly disable it.
UPDATE:
The issue I had was testing it. When I deployed my application to localhost I did not see any of the cookies being marked as HttpOnly. I was using Chrome and auto-deploying my application, before I turned on the developer tools. The initial request contained the header marking it as HttpOnly. You can confirm it by easily using JSF and the method below. Simply invalidate the session while using the developer tools and examine the response returned.
I got a response header like the one below.
Labels:
development
,
glassfish
,
Web
Tuesday, January 08, 2013
Internet Explorer 9 (IE9) Table White Space Issues
I was tasked with fixing a problem in our product where one of our data tables (HTML) was rendering on IE9 with spaces randomly scattered throughout the table this resulted in the data being in the wrong columns, or headers appearing in the wrong place. I originally thought I might there might be "holes", or null values in my data which was resulting in the error. I was wrong.
It is actually a bug in IE9.
The issue shows up, most often, when using AJAX when there is partial page rendering. It seems according to forum remarks to be focused on white space between table tag elements like line breaks, spaces, or carriage returns. So if you use HTML tidy, you will screw up your output. Nice one Microsoft!
Fortunately, there are "fixes" out there to help you get along. Here is the fix which I slightly modified from an answer on stackoverflow. A shout out goes to Blago for his recursive function listed below.
You can implement it this way.
Here are some references on the issue if you are interested.
It is actually a bug in IE9.
The issue shows up, most often, when using AJAX when there is partial page rendering. It seems according to forum remarks to be focused on white space between table tag elements like line breaks, spaces, or carriage returns. So if you use HTML tidy, you will screw up your output. Nice one Microsoft!
Fortunately, there are "fixes" out there to help you get along. Here is the fix which I slightly modified from an answer on stackoverflow. A shout out goes to Blago for his recursive function listed below.
You can implement it this way.
Here are some references on the issue if you are interested.
Labels:
AJAX
,
development
,
Internet Explorer
,
jQuery
,
stackoverflow
,
Web
Thursday, November 15, 2012
Annoying IE9 CSS Hover and Overflow Issue
Case
I have a<table/>
which is surrounded by a <div/>
which has the attribute style="overflow:auto". The table has a hover attribute to highlight table rows on mouseover. Additionally, There are some checkboxes arranged in a table below it, but it could be another element. When you mouseover the table in the div, the checkboxes start moving the the bottom of the page.
Resolution
I found the following bug posted on the jQuery bug tracker: Problem with .hover() and IE9 that describes the behavior. Brian Richards, who is linked to in the bug, has a simple bug elegant fix that worked for me.In his blog post, IE9 Hover Bug Workaround, he simply added min-height:0% to the style.I hope that the solution works for others who may encounter the problem. I also found another blog to put on my blog roll to keep an eye on. Thanks for blogging Richard.
Labels:
Design
,
development
,
Web
Tuesday, November 13, 2012
JDK7 vs. JDK 6 File Monitoring
One of the really nice advancements, or features of Java 7 is the
However, the question of how to do it on JDK 6 was posed to me for those who can't do an upgrade for business reasons. I did a quick Google search to see what was out there. Alas, some of the most popular search results were poor, or really badly implemented solutions. I did come across a nice piece of code done by Pascal Essiembre. I didn't find much more on the developer. I would give a link to his work if I were sure that what I found was him. Pascal wrote the code below which is EPL 1.0 so you are free to use it. I used it to check it out, and it works likely in the same manner as the "primitive" implementation in JDK7. Here is the code unmodified from the form I found. This is very nicely done. Good code lives on. I just wish this were more near the top of the search results.
Thanks Pascal for your code contribution to the Java community.
WatchService
. This feature takes advantage of the OS file event notification facilities where available, or otherwise uses a "primitive" polling mechanism. In my blog article WatchService Using ScheduledExecutorService Example, I show an example of how to use the WatchService along with an ExecutorService to do file monitoring. This is really easy to implement and use.However, the question of how to do it on JDK 6 was posed to me for those who can't do an upgrade for business reasons. I did a quick Google search to see what was out there. Alas, some of the most popular search results were poor, or really badly implemented solutions. I did come across a nice piece of code done by Pascal Essiembre. I didn't find much more on the developer. I would give a link to his work if I were sure that what I found was him. Pascal wrote the code below which is EPL 1.0 so you are free to use it. I used it to check it out, and it works likely in the same manner as the "primitive" implementation in JDK7. Here is the code unmodified from the form I found. This is very nicely done. Good code lives on. I just wish this were more near the top of the search results.
Thanks Pascal for your code contribution to the Java community.
Labels:
concurrency
,
development
,
example
,
Java
,
JDK6
,
JDK7
,
tutorial
Friday, November 02, 2012
Servlet 3.0 and JSF 2.x Tip of the Day: JSF Forward to External Servlet in Different Context
I posted a previous postServlet 3.0 Tip: How Do I Get to Another Servlet Context? which demonstrates how to get to another context. This extends that discussion by showing how to forward a JSF request to the other context and have the servlet output the results.
Here is the basic code to be called from the JSF page.
Here is the method.
Here is the servlet I called.
Here is the method.
Here is the servlet I called.
CrossAppServlet.java
Success
Note: If you were going to pass it to JSF, you would need to remove the view state since the Faces Servlet receiving the values would result in aViewExpiredException
since this view state is not in the target Faces Servlet.
Thursday, November 01, 2012
Servlet 3.0 Tip: How Do I Get to Another Servlet Context?
This was a question I got tonight. It was a little more complicated prior to Servlet 3.0, but now it is very easy. In fact I almost thought it was not worth writing a post about it. Then I asked a friend in IM if he knew how to do it. It was so much more complicated, I decided to capitulate and post my response.
So how do I navigate to another web application on the server from my current application context?
Simple...
So how do I navigate to another web application on the server from my current application context?
Simple...
Labels:
development
,
example
,
glassfish
,
Java
,
JavaEE
,
JEE6
,
Netbeans
,
Programming
,
tutorial
Dynamic Servlet Registration Example
Today I wanted to load a servlet dynamically, and decided to figure out how to do it. It turns out to be really simple.
I created a
We can then deploy the project and watch the magic. Here is the Apache Maven project: dynamic-servlet.zip
I created a
ServletContextListener
and annotated it. In the contextInitialized()
method, I set the servlet name, its class, and a mapping and we are done.
We can then deploy the project and watch the magic. Here is the Apache Maven project: dynamic-servlet.zip
ServletContextListenerImpl.java
ExampleServlet.java
Labels:
development
,
example
,
Java
,
JavaEE
,
JEE6
,
Netbeans
,
Programming
,
tutorial
Wednesday, July 04, 2012
Tip of the Day: Code Review Checklist
Over the last few days, I have published some code review tips of the day. This post actually contains a link to a Microsoft Word Document with those tips in checklist format.
Code Review Checklist.docx
Code Review Checklist.docx
Labels:
Design
,
development
,
Java
Tip of the Day: Performance Code Review
Performance
Here are some general best practices to consider around performance code review.These tips are by no means definitive, but serve as reminders to developers what they should consider in a checklist.
Note: performance code reviews are really not separate processes from a general code review.
- Objects are duplicated only when necessary. If you must duplicate objects, consider implementing
Clone
and decide if deep cloning is necessary. - No busy-wait loops instead of proper thread synchronization methods. For example, avoid
while(true){ ... sleep(10);...}
- Avoid large objects in memory, or using
String
to hold large documents which should be handled with better tools. For example, don't read a large XML document into aString
, or DOM. - Do not leave debugging code in production code.
- Avoid
System.out.println();
statements in code, or wrap them in a boolean condition statement likeif(DEBUG) {...}
- "Optimization that makes code harder to read should only be implemented if a profiler or other tool has indicated that the routine stands to gain from optimization. These kinds of optimizations should be well documented and code that performs the same task should be preserved." - UNKNOWN.
Note: I found this gem a few years ago, but it is so true. If anyone knows who said this, please comment.
Labels:
Design
,
development
,
Java
Tuesday, July 03, 2012
Tip of the Day: Error Handling Code Review
Error Handling
Here are some general best practices to consider around error handling code review.These tips are by no means definitive, but serve as reminders to developers what they should consider in a checklist.
Note: error handling and general code reviews are really not separate processes.
- Invalid parameter values are handled properly early in methods (Fast Fail).
NullPointerException
conditions from method invocations are checked.- Consider using a general error handler to handle known error conditions.
- An Error handler must clean up state and resources no matter where an error occurs.
- Avoid using
RuntimeException
, or sub-classes to avoid making code changes to implement correct error handling. - Define and create custom
Exception
sub-classes to match your specific exception conditions. Document the exception in detail with example conditions so the developer understands the conditions for the exception. - (JDK 7+) Use try-with-resources. (JDK < 7) check to make sure resources are closed.
- Don't pass the buck! Don't create classes which throw
Exception
rather than dealing with exception condition. - Don't swallow exceptions! For example
catch(Exception ignored) {}
. It should at least log the exception.
Labels:
Design
,
development
,
Java
Monday, July 02, 2012
Tip of the Day: Unit Testing Code Review
Testing
Here are some general best practices to consider around unit test code review.These tips are by no means definitive, but serve as reminders to developers what they should consider in a checklist.
Note: unit testing and code reviews are really not separate processes.
- Unit tests are added for each code path, and behavior. This can be facilitated by tools like Sonar, and Cobertura.
- Unit tests must cover error conditions and invalid parameter cases.
- Unit tests for standard algorithms should be examined against the standard for expected results.
- Check for possible null pointers are always checked before use.
- Array indices are always checked to avoid ArrayIndexOfBounds exceptions.
- Do not write a new algorithm for code that is already implemented in an existing public framework API, and tested.
- Ensure that the code fixes the issue, or implements the requirement, and that the unit test confirms it. If the unit test confirms a fix for issue, add the issue number to the documentation.
Labels:
Design
,
development
,
Java
Sunday, July 01, 2012
Tip of the Day: Documentation Code Review
Documentation
Here are some general best practices to consider around documentation code review.These tips are by no means definitive, but serve as reminders to developers what they should consider in a checklist.
Note: documentation and code reviews are really not separate processes.
- All methods are commented in clear language. If it is unclear to the reader, it is unclear to the user.
- All source code contains @author for all authors.
- @version should be included as required.
- All class, variable, and method modifiers should be examined for correctness.
- Describe behavior for known input corner-cases.
- Complex algorithms should be explained with references. For example, document the reference that identifies the equation, formula, or pattern. In all cases, examine the algorithm and determine if it can be simplified.
- Code that depends on non-obvious behavior in external frameworks is documented with reference to external documentation.
- Confirm that the code does not depend on a bug in an external framework which may be fixed later, and result in an error condition. If you find a bug in an external library, open an issue, and document it in the code as necessary.
- Units of measurement are documented for numeric values.
- Incomplete code is marked with //TODO or //FIXME markers.
- All public and private APIs are examined for updates.
Labels:
Design
,
development
,
Java
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...