Good java/j2ee app shared hosting December 19, 2006
Posted by javafoo in hibernate, java, java hosting, javanotes, struts basic.1 comment so far
…is non-existent. Sorry I let the title fool you. So, I have been working on this small project (struts, hibernate, mysql stack) on the side. No the project did not warrant the need of java, I could have hacked it in good ol’ perl/PHP/Python, take your pick. But the people(University of ..midwest) who wanted it done, thought java was cool and the help that I got, could only program in java (yes, this is the case mostly, you can hardly find programming language agnostic programmers these days). I digress, anyhow, the app was done, everything seemed to work on my trusty laptop. The demo went fine and the client asked to have it deployed. They left the hosting to me. Piece of cake huh! Hardly, I discovered. It’s the ‘E’ for enterprise in j2ee, it’s just not meant for shared web hosting, you are better off with dedicated servers and your own IS staff to maintain it. Most of the shared service providers will not give you your own java VM and/or tomcat/jboss/resin to play with, the security policy files are too restrictive(rightly so, it’s their server they don’t want you to muck around) and you will need to know all the libraries in your app that will need permissions (mostly by trial and error). The support staff are *nix demi-gods, most of them will reply promptly, even at unearthly hours(they need to get a life), but will draw a blank with any Java webapp help. All in all not a pleasant experience. Of course this has changed a bit now, there are some mature java webapp aware hosting providers out there, you can find them with a little googling. But it comes at a premium, not really helpful when you are on a budget. So if your project is small and you can get away with some simple scripting language-mysql magic, that can be hosted on the $19.99/month hosting service in the midwest, put your foot down, educate the client, stay away from java. Yeah, I know this piece of advice, coming from javafoo. But that’s how it is.
Struts mapping actions September 21, 2006
Posted by javafoo in javanotes, struts basic.1 comment so far
In this latest project of mine I was thinking about the various ways to map struts actions. I had done this, a couple of different ways and was wondering if there was a classification out there. And sure enough someone had already done this and instead of paraphrasing, I will just provide the link, here at TSS. Another thing/caveat about using named form-beans accross actions For ex, in your struts-config.xml, if you have a form-bean:
<form-bean name=”xyzForm” type=”package.web.XYZForm” />
and you want to use the same form accross two actions:
<action path=”/processAction” type=”package.web.action.ProcessAction”
parameter=”process”
name=”xyzForm” validate=”true”…..
<action path=”/displayAction” type=”package.web.action.DisplayAction”
parameter=”display”
name=”xyzForm” validate=”false”….
Notice here, I am using the same named form-bean for two actions, in the display action I don’t want to validate the form, but in the process action I want to validate the form. In this case I was in for a surprise, the validate=”true” wasn’t working for the process action. This is because the form params are set only once per form-bean. To overcome this, define two different named form-beans of the same type or if you still want to reuse the form-bean, set validate to true for both actions and within the validate method, based on a parameter decide if you want to validate or not.
Struts action, parameter attribute June 29, 2005
Posted by javafoo in javanotes, struts basic.3 comments
My gripe about this generic attribute called ‘parameter’ in the struts action config.
So I have something like:
path=”/logonProcess”
type=”naive.actions.LogonAction”
name=”logonForm”
parameter=”/pages/Logon.jsp”
validate=”true”
Now someone pray tell me what this ‘paramter’ is supposed to do.
I looked up on the Apache site and it says:
“action general purpose configuration parameter”.
Alright, but what is that supposed to mean. Well it means different things to different action type classes, if it is a ForwardAction it can be the url you want the action to be forwarded to. For DispatchAction it is the key to the different method values. Also you can pass your own parameters that can be available to the action.
Playing with Struts Day 1 June 27, 2005
Posted by javafoo in javanotes, struts basic.add a comment
Ok, so finally after looking at much examples, I thought I had a basic idea and this was too trivial to actually go about trying. But today out of sheer boredem, I exported the struts-blank.war into Tomcat and got hacking at it. So here goes my tryst with struts:
- 2:15 PM Ok then, I edit struts-config.xml: create a simple logonForm extending DynActionForm, add action logon, map the action to logonForm and a LogonAction class, that I will code in a bit.
- 2:30 PM I create the jsps using the tags.
- 2:40 I get interrupted, they want me to do some work actually.
- 3:30 PM Ok where was I? Right the jsps; I write a simple action class: LogonAction, in which I check the username and password against hard-coded values and if they match, forward the page to success, if not forward to failure.
- 3:35 PM I am all compiled and ready to go, I fire up Tomcat and go to the logon page.
- 3:40PM Hurrah! I can actually see the logon page, I hit submit, the page goes to logon.do, but empty page.
- 3:45 PM I think there might be something wrong in the Action class, so I comment the very cryptic username, password checking logic and just forward the page to success. I fire up Tomcat again.
- Fast Forward: a few iterations, debugs, logs and System.out.println later:
- 4:30 PM Still no luck, also anything I log or write to sysout does not show up in the logs, so probably the action calss is not even getting invoked.
- 4:45 PM I tear out my hair, google for “struts action empty page”, there is something about previous Action API requiring you to implement perform and current ones needing you to implement execute.
- 5:00 PM So, sure enough I am impelmenting perform, I just change this to execute and try again, Hallelujah!, I am strutting away to glory.
Moral of the story when in “Action”, “execute”, do not “perform”.
So much for struts.