The wife let me get one of these. I’m pretty excited about it…
All posts by ajohnson
Core Servlets & JSP Book
On the subject of free books, Marty Hall’s book Core Servlets & JSP is available for free as well, you can download the PDF here.
Requesting a URL securely
We had a thread going at work about finding out if the user is requesting a URL securely, ie: using HTTPS. Various methods were thrown about: getScheme(), getProtocol(), getServerPort()… We missed the most obvious one: isSecure()
Application settings when using servlets
I posted some notes a couple weeks ago about .NET configuration files, came across the code for doing the same thing in a servlet container tonight. Basically, you get a ServletConfig object using the getServletConfig() method of the Servlet interface and then call getInitParameter(String initParamName) on that. For example, let’s say that I put a global database connection string in my web.xml deployment descriptor:
<web-app>
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>MyServlet</servlet-class>
<init-param>
<param-name>connection_string</param-name>
<param-value>user id=sa;password=mypassword;initial catalog=mydb;data source=mydbserver;Connect Timeout=30</param-value>
</init-param>
</servlet>
</web-app>
Then, in my servlet code init() method, I could write this:
ServletConfig sc = getServletConfig();
String connection_string = sc.getInitParameter(“connection_string”);
After retrieving the value from the ServletConfig object, you’ll probably want to store it for later use in the ServletContext object:
ServletContext c = getServletContext();
c.setAttribute(“connection_string”, connection_string);
Now I can get the connection string in a JSP or a servlet later using this short snippet:
String myCS = (String)getServletContext().getAttribute(“connection_string”);
Free J2EE and XML Development Book
Manning Publications is offering their J2EE and XML Development book for free as a PDF on TheServerSide
New Portal Launched: PatternsCentral.Com
From TheServerSide.com: New Portal Launched: PatternsCentral.Com: “PatternsCentral is a portal website and supporting e-newsletter aimed at the growing community of architects, designers, and developers using pattern-based development for enterprise and web-based applications.“
user level security in apache
I needed to lock down a couple directories on this server using Basic Authentication in Apache… in case you’ve ever wanted too, or someday will need too:
1) Add the username to the password file using the htpasswd module:
# htpasswd /etc/httpd/users username
where ‘/etc/httpd/users’ is the name of the file you want your users/passwords stored and ‘username’ is the username you want to add. It’ll ask you for the password, and then again before adding the user to the file. If the file doesn’t exist, usr the -c flag to create the file:
# htpasswd -c /etc/httpd/users username
2) Then add a .htaccess file in the directory you wan to secure that contains this:
AuthName “username”
AuthType Basic
AuthUserFile /etc/httpd/users
require user username
where ‘/etc/httpd/users/’ is the name your passwd file and ‘username’ is the name of the user you want to allow in this directory.
Business Jargon
Veen comes up with a pretty humorous list of jargon he’s found while consulting for a large organization. My personal favorite is ‘boil the ocean’.
Gandhi’s Truth
I finished “Gandhi’s Truth: On The Origins of Militant Nonviolence” this morning. I won’t try to summarize what Erik Erikson wrote over 450 pages, but here are a couple quotes I found worth remembering:
“… I must reduce myself to zero. So long as a man does not of his own free will put himself last mong his fellow creatures, there is no salvation for him. Ahimsa is the farthest limit of humility.” [pg 59]
“… I will not forget the consternation which I caused in some of Gandhi’s odl friends when I asked them to stand up and show me how tall he was as compared with them. It became clear that, while in fact small, he seemed immeasurable. The passing of such a pervasive light leaves the dark even darker and the once-enlightened suddenly forlorn. For the numinous person has the strange power to make the participant feel part of him and yet also feel augmented in himself; and both of these augmentations are apt to wane when the great moment is over.” [pg 63]
Heinrich Zimmer summarizes the meaning of dharma as: “The correct manner of dealing with every life problem that arises, therefore, is indicated by the laws (dharma) of the caste (varna) to which one belongs, and of the particular stage of life (asrama) that is proper to one’s age. One is not free to choose; one belongs to a species — a family, guild, and craft, a group, a denomination. And since this circumstance not only determines to the last detail the regulations for one’s public and private conduct, but also represents (according to this all inclusive and pervasive, unyielding pattern of integration) the real ideal of one’s present natural character, one’s concern as a judging and acting entity must be only to meet every life problem in a manner befitting the role one plays…” [pg 75-76]
“.. In all of Gandhi’s utterances … two themes stood out, new in the independence movement: never start what you have not clearly circumscribed in your own mind or what you are not ready to suffer for to the very end.” [pg 89]
In regards to the desire Gandhi had to be untainted and unsmudged: “Mere character could be, as it were, a cold chimney, nothing more than an encasement. A fireplace is not worth more than the fire it can hold and warmth it can generate; and a man like Gandhi, I would surmise, early knew that he had to contain a superior energy of destructive, as well as benevolent, forces..” [pg 101]
On the difference between Indians and Westerners: “… the very qualities of Indians count for defects in South Africa. The Indians are disliked in South Africa for their simplicity, patience, perseverance, frugality, and otherworldliness. Westerners are enterprising, impatient, engrossed in multiplying their material wants and in satisfying them, fond of good cheer, anxious to save physical labor and prodigal in habits.” [pg 190]
An illuminating quote in relation to the chaos that enveloped Baghdad in the days following the initial US occupation: “The point is that excess and riot follow repression and suppression when the moral restraints are lifted, precisely because of the autocratic and blind nature of those restraints…. nonviolence, inward and outward, can become a true force only where ethics replaces moralism. And ethics, to me, is marked by an insightful assent to human values, whereas moralism is blind obedience; and ethics is transmitted with informed persuasion, rather than enforced with with absolute interdicts.” [pg 251]
On our identities, who we are: “For membership in a nation, in a class, or in a caste is one of those elements of an individual’s identity which at the very minimum comprise what one is never not, as does membership in one of the two sexes or in a given race. What one is never not establishes the life space within which one may hope to become uniquely and affirmatively what one is — and then to transcend that uniqueness by way of a more inclusive humanity.” [pg 266]
Nokia 3650
Russell posted an extra long description of why he wants the Nokia 3650 on Mobitopia. This phone seems to be the next ‘big one’, Jeremy Allaire’s got one as well… It’s got everything my phone has, plus video recording, plus camera, plus memory expandability, plus Java MIDP 1.0, plus Symbian. By the way, my phone, the Sony Ericsson T68i, don’t bother, it gets absolutely horrible reception (either that or T-Mobile sucks). It drops just about every call I’m on, I frequently miss calls and I frequently have no service. Not happy about that at all. Maybe I can convince the wife that I need a 3650 as well.
In some sense I guess I’m getting what I deserve: I dropped Sprint after 2.5 years of great service for a phone that had all the gizmos, only to find out that the one thing I really want to do on the phone is uh… make phone calls.