Alejandro Galvan

Ranch Hand
+ Follow
since Jan 02, 2008
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 Alejandro Galvan

Hi,

Have you tried Displaytag? it gives you a table from a list previosly setted in the request scope, it can show all the attributes, or just what you defined, in columns, check it at: its site

Good luck,
15 years ago
Hi,

The default config file for Log4j should be named log4j.properties and must be placed on the root of the application's classpath, but Log4j is highly configurable, please refer to the page I previously gave you and go to the "Example Configurations" section. Also, if you want more help, maybe the rigth forum for this topic should be: "Other Open Source Projects", please go there and post your questions, since this seems not to be related to Struts.

Regards,
15 years ago
Hi,

First, seems that this is not the correct forum, but right now I can not think in a proper forum.

I suppose you also have the commons-logging jar in your WEB-INF/lib folder. The code you are using:

is from commons-logging API, not from Log4j.

The normal way to get the logger for Log4j is:


Go to the Log4j Manual site and read more about.

Hope this helps you.


Regards,
15 years ago
Hi,

Are you using your Eclipse or MyEclipse? The Action classes you want to compile are those that you wrote? Normally IDE's can automatically compile your code, so, if you want to compile your code, most probably it is already done by the IDE (look into your workspace on your file system), and when you deploy your app into a server the IDE will just move the compiled code to the AS.

Maybe this kind of question is for the IDE's forum. Please let us know if this information is enough or you have more doubts about struts.
15 years ago
Hi Kareem,

The link you posted is for the SCJP 6.0 exam, if you plan to take the SCJA exam, the objectives are here. I would recommend you, whichever you take to buy a good book, for SCJP, one of the most recommended books (and one of the most used on the SCJP JavaRanch Forum) is the SCJP 6.0 by Kathy Sierra and Bert Bates (look it at amazon.com) and it comes with some mock exams, it's really good, I'm not quite sure about a good recommendation for SCJA, but you can search amazon.com and/or ask in this forum for other recommendations.

Regards,
15 years ago
Hi Gijs,

First of all, my apologize if I wrote a bit harsh, was no my intention. Second, it is not matter that I don't belive you, I really belive you cause it is possible, but as I told you, you should not base your answers in probability and, as you already see:

Gijs Peek wrote:
Anyway, in the answer to question 11 the book mentions that for the purpose of the exam, the hashCode implementation in object does produce unique hashcodes (as far as I can see, they don't mention this earlier in the chapter).



This room is for SCJP purposes, and so do the S&B book, then, and based in your comment I quoted, the book has no errata, and your answer, in the real exam, should be as explained in the book.

However I'm quoting here some other texts for one of the questions you gave me:

Gijs Peek wrote: I don't know where you read that two different objects will have two different hashcodes, but this does not seem to be true.



I don't know if you are aware of the API, if you don't, check it, it is a good place to know the entire Java Application Program Interface, go to http://java.sun.com/javase/6/docs/api/, there, navigate to class java.lang.Object and you'll find the method hashCode and its explanaiton:

hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.
The general contract of hashCode is:

Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)


Returns:
a hash code value for this object.
See Also:
equals(java.lang.Object), Hashtable



Also, I'm posting here the put method from the HashMap class (you can download the source code from the Sun Microsystems site):


So, hopefully this helps you in the exam and, I want to congratulate you because your great research and, again, my apologize.

Regards,
Hi,

I tried to replicate your experiment as:


And I didn't get a "2" in the output, I think you should not base your answers in probability, you should read and understand better how the compiler and the JVM works if you want success, the answers given by the book are correct, remember that, when hashCode is not overriden, it use the method from the super class (in this case from class Object) and that method from Object class return the memory address of the object, so, two different objects will have two different hashcodes, so the equals method won't be called.

Regards,
Hi:

Originally posted by Duran Harris:
if((++x>2)>||(++y)>2)



In the (++x>2)> expression, is the last greater-than symbol correct? Cause, if it is in your code, it won't compile, if it is not in your code, the output is as said by Punit.

Regards,
[ January 02, 2009: Message edited by: Alejandro Galvan ]
Hi,

In case of final variables to primitive types, you can not change its value, because, in memory, the value of that variable is in the same memory slot that the variable itself, but in case of final variables that refer to objects, the only thing is final is the reference to the object, I mean, in an variable that refer to an object the only thing that is on that variable is the memory address to the object, so, you can not make:


The object itself is on other memory place (called the "heap") and it's not final so, lets say your class A has a public int attribute called aa that is not final, like:


So it is allowed to change the aa's value, like:


As I know, you can not change the value inside a wrapper class, but the compiler does not see the wrapper class, it just see it is an object and that is not allowed in a switch-case statement.

Hope this is clear, regards,
[ December 29, 2008: Message edited by: Alejandro Galvan ]
That coma is not doing anything special, as Jesper said, it is just allowed by the compiler but does not determine the array length, if you try the sample given by Punit:


int [] arr={1,2,3,};
System.out.println(arr.length);

int [] arr1={1,2,3};
System.out.println(arr1.length);



You'll have the output:


3
3



also if you try to add the fourth element to the array with the extra-coma, like:

arr[3] = 4;


you'll get an ArrayIndexOutOfBoundsException

Even if the coma determines the array length, then you would be able to put something like:

int [] arr={1,2,3,,,};


But the compiler does not allow more than one extra-coma

Hope this help you.

Regards,
Attributes within a request just live in that request, so, if you are calling one of your action classes from (lets say) a jsp, and then it gets back to another page and from that second page you call another action class, it is a different request, so the the attribute in your first request is no present in the second one, the first one just died, if you want more life time to the objects you can set the attributes in the session scope, like:

but that is not a completelly smart way
15 years ago
Have you tryied to change your jar files to some jdk 1.4 compatible, like struts-1.2?
15 years ago
Try creating your project as "Web Project" not as "Dynamic" or "Static", those "Dynamic" and "Static" types are inherited from the pure Eclipse, if you are using MyEclipse, you can simply create the "Web Project" and it can be added with struts and other capabilities.

Regards,
Hi Ashvini,

I think you are talking of struts' action classes, if so, there is a forum in JavaRanch about struts. First, since the action's execute method's signature and its collaborations with other struts' classes are already defined, you can not simple add the Map as a parameter, you should read about the use of struts and the struts' forms (like ValidatorForm) within jsp's.

Hopefully, if you post this in the struts forum, you can get better response.

Regards,
Hi Preetha,

Checked exceptions are those that the compiler checks if are caught or thrown, this means, if some method throws an exception (defined on its method signature) and, in your code, you call that method, you always should catch it in or throw it, normally, any exception extending the Exception class (but not the RuntimeException class) is a checked exception.

As Djonatah said, those are mainly the developer's thrown exceptions, but you need to understand why, the exceptions thrown by developers are mainly caused by the code the developer made, either by a mistake or intentionally.

Hope this helps you.

Regards,