This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Now once an IOException occurs, I am wondering what I should write in "errors.jsp" to display that "THis is an IO error" ? It may be easy for some of you, but I just don't know. never done it. I tried adding a <html:errors/> in it but it doesn't grab that line. What if I want to display that line plus getting more exception information ? Any help will be appreciated.
thanks.
Artemesia Lakener
Ranch Hand
Joined: Jun 21, 2005
Posts: 162
posted
0
still have no clue on this. Should I use some "message" kind tag to do it ? What I tried is to put <html:errors/> in the generalerror.jsp and it does show the specific Exception type but it does NOT display what I put in the ApplicationREsources.properties file. Any idea ?
Do your methods all pass the exceptions on up, or handle them? Make sure that this exception is not being caught anywhere else in your code.
Steve
Artemesia Lakener
Ranch Hand
Joined: Jun 21, 2005
Posts: 162
posted
0
Originally posted by Steve McCann: Do your methods all pass the exceptions on up, or handle them? Make sure that this exception is not being caught anywhere else in your code.
Steve
my methods pass those exceptions on.
Artemesia Lakener
Ranch Hand
Joined: Jun 21, 2005
Posts: 162
posted
0
Is it true that only for "handled" exception we can use the error key stored in ApplicationResources.properties ? If it is handled by us, we can use "ActionMessage" to add the error and then the error will be displayed based on its "key" entry in the properties file. If the error is not handled and just thrown all the way up, I guess whatever I put in the ApplicationResource.properties will not be used at all. The system will the msg in its own way. Is my understanding correct ?
Steve McCann
Ranch Hand
Joined: Oct 20, 2004
Posts: 81
posted
0
we can use "ActionMessage" to add the error and then the error will be displayed based on its "key" entry in the properties file.
As I understand things, you can use the ActionMessage class to get any messages in the ApplicationResources.properites file - not just for Exceptions.
You don't say where in the struts-config.xml you have placed this exception. The <exception> tag must be within either <action> or <global-exceptions>. If inside <action> then this exception will be picked up and handled by only the specific Action. Try moving it into the <global-exceptions>.
Artemesia Lakener
Ranch Hand
Joined: Jun 21, 2005
Posts: 162
posted
0
Originally posted by Steve McCann:
You don't say where in the struts-config.xml you have placed this exception. The <exception> tag must be within either <action> or <global-exceptions>. If inside <action> then this exception will be picked up and handled by only the specific Action. Try moving it into the <global-exceptions>.
Thanks. Actually I do put it in <global-exception>. What stopped me is what to write in the error.jsp page to display that particular type error's ms defined in the .properties file. You mentioned using ActionMessage. Could you show me a very simple example of how ?
Originally posted by Merrill Higginson: Just put the tag:
<html:errors/>
in your JSP. Struts will automatically populate it with the error message when it forwards to the JSP.
that's what I have tried. It does show the type of exception but it does *not* explicitly display that "This is an IO error" String indicated in the properties file
ApplicationResource.properties:
** error.io=<P>This is an IO error</P> ... ... ***