Cesar Olavo

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

Recent posts by Cesar Olavo

Bingo! When I started this thread some time ago I was a bit hurried to have my code working, so I didn't bother to check what was really happening, why I was getting that missing ArrayStack message and why having a new java install solved my problem.

Now, less pressed, it took me no more than 5 minutes to see that Bill was right. THe problem is that there was a damn old commons-digester.jar (not commons-collection, as Bill suggested, but it was a good hint anyway) hanging around in the jre/lib/ext of the old java install. Once removed, no more problems. And as an extra bonus, now tomcat is displaying some new juicy messages that will help me debug old problems with log4j...

Thanks again Bill.

Cesar
18 years ago
Thank you for your response, Bill. I solved the problem by reinstalling the jsdk. In some way the struts application corrupted the java files.

Cesar
18 years ago
Hi all,

I cannot find a way out for this exception during tomcat booting process. It began with a tomcat version bundled with StrutsStudio. Then this "virus" arrived in my tomcat's main installation. I even downloaded a new one (v.4.1.31)and installed in a completely different directory and once again the same message:

java.lang.NoClassDefFoundError: org/apache/commons/collections/ArrayStack

I suppose this is a class used by tomcat's digester to read the configuration files. Needless to say that I already checked and ALL installations have the commons-collections jar.

Any hint?

Thanks in advance,

C�sar
18 years ago

Originally posted by Dilip kumar:
I'm not sure if article in below link answers your question but it has good explanation for Web services with Struts applications

http://www-128.ibm.com/developerworks/webservices/library/ws-arcstruts/



This article suggests an architecture matching ws and struts. However I couldn't compile the example, because it needs an API (import com.tbf.xml.* from a company long gone. So, if somebody has been succesful in compiling this program, please let me know.

Cesar
18 years ago

Originally posted by Suneesh Raman:

How the browser automatically identify the corresponding property file as per the local.



In fact is not the browser that identifies... it just sends the language he prefers (YOU configure that) in the header:

Accept-Language: pt-br

All the ResourceBundles are loaded by the JVM and if there is one named ApplicationResources_pt-br, this is the one your application will use to "translate" the keys. Otherwise it will use the default.

Cesar
18 years ago
Hello,

You don't need to map the taglib in the web.xml. From Servlet 2.3 (Tomcat 4.1, for example), JARs in WEB-INF/lib are inspected for .tld files in their META-INF directory. If a .tld file exists, its URI can be used in your JSPs without having to define any taglibs in web.xml. Please check if you have all the needed jars.


Cesar
18 years ago
Hi,

Can anyone explain why we need the ApplicationResources declared twice, i.e. in the web.xml and in the struts-config?

web.xml:

<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>

struts-config:

<message-resources
parameter="ApplicationResources"
null="false" />

Thank you,

Cesar
18 years ago
hi,

Not seeing any reason why this stream example wouldn't work, I implemented it verbatim and, believe me, it worked both in the localhost and in a remote host. So, unless your html page is faulty (did you try to see it direct from the filesystem?) it should work for you too.

Cesar
18 years ago
JSP
Ooops,

Please reconsider the posting above. It's not exactly an answer for what you asked. The example I gave is a way of retrieving class objects, but *not* the one you asked. In fact Object.getClass() and Class.forName() have slightly different usages:

Class c = myObj.getClass(); (class name is unknown, but there is an instance available)

Class c = Class.forName(strg); (class name is unknown at compile time, but available at runtime)

Cesar
18 years ago
Hi,

You can also use getClass() to keep your code easier (to maintain). For example, if you want to add logging to a dozen classes, using Jakarta commons-logging, you can cut and paste this code snippet to all of them:



The alternative way would be to have a different code in each class (changing ClassOne.class for the corresponding class):



Cesar Moura
18 years ago
Hi Shyam and Laine,

You both are absolutely right. Thank you for your explanations. Now the things seem clearer to me.

Cesar
18 years ago
Hi Shyam,

Thank you for you reply.


And the constructor prints out the first message. Then when the exception is finally caught it prints out the second message.
...
An exception is caught only after it is thrown.



You're right. I must confess my question was badly phrased though. What I really meant was:

Catching an exception means: "ok, the long-awaited event happened, but forget about the exception handler, I'm gonna handle this exception myself with the code in this catch clause."

Or not? Otherwise we would always have two codes executed -the catch and the handler (with that dreadful stack traces...)


Most probably, the function of the main() method is to print the Stack trace if it is declared to throw exceptions.



You mean the main method behaves differently from a regular one?


Cesar
18 years ago
Hi all,

I'm trying to understand excption in java and confess the results were not as antecipated:


and


The questions are:

a) if I comment out the part 2 (only the line with the myMethod2 call, exactly as shown in the listing above) I get the the response below. Why do we see two messages? I thought that capturing one exception meant NOT to throw it.

D:\javastuff\temp>java ExceptionTest
myException has been thrown
myException has been captured

b) On the other hand, if I comment out the part1 (the try/catch block) I get the result below. Why, unlike the case a) above, is the stack trace shown?

D:\javastuff\temp>java ExceptionTest
myException has been thrown
Exception in thread "main" MyException
at ExceptionTest.exceptionThrower(ExceptionTest.java:5)
at ExceptionTest.myMethod1(ExceptionTest.java:11)
at ExceptionTest.myMethod2(ExceptionTest.java:17)
at ExceptionTest.main(ExceptionTest.java:28)

Thanks,

Cesar Olavo
18 years ago
Yeah I did it (don't ask me why I didn't before;-). Both are right. What the container inlines in compilation time is the *code* not the *result*. That is why we always get updated times.

Thank you guys. You're masters.

Cesar
18 years ago
JSP
like this:

<%
java.util.Calendar now = java.util.Calendar.getInstance();

int hour = now.get(java.util.Calendar.HOUR_OF_DAY);
int minute = now.get(java.util.Calendar.MINUTE);
int second = now.get(java.util.Calendar.SECOND);

if (hour<10)
out.println("0" + hour);
else
out.println(hour);

out.println(":");

if (minute<10)
out.println("0" + minute);
else
out.println(minute);

out.println(":");

if (second<10)
out.println("0" + second);
else
out.println(second);
%>


Cesar
18 years ago
JSP