Paul Gilette

+ Follow
since May 09, 2001
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Gilette

The editor can be Java-aware just as easily. (Probably more easily, because those parsers are already build into most Java development tools.)
22 years ago
I want to do something like the following, but I can't get it to work:
<bean:message key="message.hi" arg0='<bean:write name="a" scope="session" property="name"/>'/>
In other words, I want to look at the session attribute "a" for a property called "name" and use it as arg0 for the bean:message. When I look at the generages Java source I see that the arg0 properyty is simply being set to the literal string "<bean:write...", rather than evaluating it.
22 years ago
Why are custom tags taken for granted as the "right" way to add functionality to JSPs? Why not just create libraries of static Java routines, then call those as JSP expressions?

Here's an example of the Struts iterate tag:
<logic:iterate id="element" name="myhashtable", scope="session">
<br><bean:write name="element"/>
Why not just code a static String method that does the same thing:
<%= HtmlUtils.iterate(session.getAttribute("myhashtable"), "<br>?")%>
Of course, you are free to make up your own parameter list -- you could have the using code pass "page", request, or response if those would be handy.
The training cost for the HTML programmer would be the same: It takes the same effort to learn a new JSP tag such as logic:iterate, as it is to learn how to call a new static method. (The static method call is probably a little simpler.)
The organization benefits because you no longer have to manage TLDs. Documentation of these static methods is easy because you use Javadoc. The organization also benefits because the learning curve for coding some static routine is lower than the learning curve for implementing a custom tag.
22 years ago
"Singleton" is a concept. The patterns book is clear that there may be many implementations of the various patterns. So even though Math is not a singleton (for reason's I'll give below), an abstract class CAN be used to implement singleton.
The purpose of a singleton is to have a single copy of data which the class methods access and update. Therefore, besides the classic "private static field with static accessor" technique, you can also just use an abstract class where its static fields are accessed and updated by its static routines. The key is that there is the one copy of data associated with the "object".
Math is not a singleton because it does not represent "a single copy of data" on which the routines act. Instead, it's just a set of utility routines to which you pass the data to be acted on.
Dan -- Doesn't Java Web Start adequately address that?
I have a philosophical question that's been nagging at me lately.
So much effort is going into Web-based application design. This has led to complex architectures (e.g., Struts), novel user interfaces (e.g., using Flash), less language standardization, high training costs, lots of confusion, etc.
Why aren't people doing "standard" GUI using Swing? There are technologies, such as Java Web Start, that appear to address the distribution issue.
Think about the years of R&D that went into standard widgets: starting with Xerox PARC, the Mac, all the Microsoft usability research, and so on. Computer users are familiar with radio buttons, check boxes, etc. And those years of application knowledge -- from CICS to VB to Powerbuilder and Delphi -- all of this experience has contributed to what we see in Swing.
So why re-think everything with these elaborate Web-based applications? Can we make Web-based applications work? Sure! But are the enormous costs needed? Do we need to re-invent how users interact with their data?
Now don't get me wrong. The Web is great for certain kinds of information. Like hyper-linked documents and applications with very simple interactions. But these days it seems like developing Web-based (browser-based) applications and architectures is a juggernaut -- moving under its own weight and inertia.
What do you think?
I'm unclear how to deploy a .war file. I created my standard sub-directory structure. On my desktop machine, I installed Tomcat and modified the server.xml file by adding a "<context" entry for the new application. Is that it? No changes to the "build.xml" file or any other file?
23 years ago
There are several ways of storing information to be shared as servlets and JSPs forward to and include each other.
I'm confused by the differences between "page context," "request context," the session, and the application. I'm also confused by what syntax to use reference these objects using Java code in a servlet versus the syntax used in a JSP.
Is there a good book or other source that clearly explains server/servlet/JSP lifecycle and clarifies the code used to reference each of these objects?
23 years ago
public class Tester {
protected Tester(){
System.out.println("I got run!");
public static void someStaticMethod(){
System.out.println("You just ran the static method");
-- Another class
public class ExtendsTester extends Tester {
public static final ExtendsTester ONE_EXTENDS_TESTER_OBJECT = new ExtendsTester();
// Many other public static final fields go here.
// There are also many other Tester sub-classes doing the
// same thing.
-- Another class
public class TesterTester {
public static void main(String[] args){
System.out.println("End of main");
If you run applociation TesterTester you'll see that the instance of ExtendsTester is NOT created.
I'm implementing a bunch of type-safe constants in this way, but I want them loaded by the time I run some routines in an ancestor class. I tried putting static initializers in the extending classes, but no soap. (In other words, putting a static initializer in ExtendsTester to create the instance also does NOT get run.)
Apparently, the reference to ExtendsTester in the main method is not enough to get Java to load the class (and thus, initialize its static fields).
Is there an elegant way to get all of the static final fields to initialize?
23 years ago
I'm famiar with servlets and JSP, but not with Web application architectures. I need advice on the quality of an approach I'm trying... Thank you for taking the time to read this note and giving me your feedback.
The application is used to view and update employee data.
The URLs will have this structure: "action/viewpage/layout". For example, http://mysite/view/detail/default?id=123
is a request to view the employee with key (123), using the view page called "detail" and the layout "default".
This works by having all requests go through a servlet called ControlServlet. The servlet fetches the object being requested and saves a reference to the object with the "request" using
request.setAttribute("requstedObject", employee);
I also save the view page request via
request.setAttribute("requestedView", requestedView);
The servlet then does a forward to the layout form (a JSP).
The layout form uses dynamic (<jsp:include page=...> )incluces to bring in standard elements, such as a header, toc, and footer. Then uses the requested view to bring in the body of the requested document. The layout JSP fetches the requested view page via
The view page displays employee data. It fetches the data by doing this at the top of the JSP
<% Employee employee = (Employee)request.getAttribute("requstedObject"); %>
It then uses that object to show employee properties, such as
<h1>Edit employee information for <%=employee.getName()%></h1>
(I'm using this technique to avoid custom JSP tags -- that's a small level of additional complexity I'd rather not get into right now.)
SO! My question is basically whether this looks like a good approach.
I'm most up in the air about how to have the employee object and view request in scope as I'm forwarding from the servlet and including in the JSP. I could store it with the session object, but I seem to recall that a session is URL-specific, therefore, the object will be unavailable as the user goes from URL to URL. I need a scope that is for ONE USER across URLs on the site.
Any suggestions or advice?
23 years ago