Ziyang Zhang

Ranch Hand
+ Follow
since Jul 17, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
8
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 Ziyang Zhang

In java, I know the data type of the result of an arithmetic calculation depends on the data types of the numbers involved in the calculation. For example,

int + int = int

long/double=double

a. But I can't find any references which can give me all these rules. Could someone help me?

b. How to avoid over flow in arithmetic calculation? For example, the results of 2 long may not fit into a long anymore...

Thanks a lot.
11 years ago
I have a windows 7 (64bit) box.
When I first got this box, I have C:\Program Files (x86)\Java\jre6. I uninstalled this by accident. this is a 32 bit jre.
Then I installed jdk6 and jre6 under C:\Program Files\Java\jdk6 and C:\Program Files\Java\jre6.

But I noticed that my browsers (chrome and IE) doesn't recognize java if I do so.
Then I go to http://www.java.com/en/download/ to download java and install, then i get my C:\Program Files (x86)\Java\jre6 back. Then java in all browsers work. (another interesting thing is http://www.java.com/en/download/ can tell you which browser you are in right now, and the downloaded installer has different names if you use different browser to download. But once you installed one, all browsers begin to work)

And another question, what is function of control panel->programs->java???

Thanks a lot.
11 years ago

Gaurav Sagar wrote:

Ziyang Zhang wrote:

Tom Reilly wrote:I assume you are referring to the Windows OS. User Parameter is used for the current user only. System Parameter is used for all users, which means it works for those applications that are run as system services. I always use System Parameter and never have to worry about the things you are worrying about.


Thanks a lot!!! Do you have any idea why java -version works all the time no matter if I install jdk or not?



java -version works because that is an executable always present in the jre (Java Run time Environment) which is shipped to you when you buy your windows OS. When you install the JDK then JRE is also installed(if you don't have a JRE or your JRE previously installed is of an older version).

So, to check the proper installation of your JDK i.e. after you have set the path, then simply enter the javac -version onto your command prompt. This would tell you the version of javac installed onto your system. It's far better to use then getting confused by the java -version(Highly Recommended).



This is very clear. Thank you so much!!!
I have a folder called jre under my jdk install directory. And I also has jre under C:\Program Files\Java.
In my understanding jre under C:\Program Files\Java is used for run some 'real' java program in my system or browser. For example, if there is a applet, this will run in the jre under C:\Program Files\Java.
What is the jre under jdk for???
Thanks a LOT!!!
Ziyang
13 years ago

Tom Reilly wrote:I assume you are referring to the Windows OS. User Parameter is used for the current user only. System Parameter is used for all users, which means it works for those applications that are run as system services. I always use System Parameter and never have to worry about the things you are worrying about.


Thanks a lot!!! Do you have any idea why java -version works all the time no matter if I install jdk or not?
13 years ago
Thank you very much for your answer!! I think the system should interpret JAVA_HOME when I log in if my "user parameter" is set. Anyway, I'm not the guy who design windows:-)
Thanks a lot!

marc weber wrote:

Ziyang Zhang wrote:...I found if I set JAVA_HOME as “User Parameter” and set path as “System Parameter” (I use JAVA_HOME when setting path). This will not work, which means % JAVA_HOME % in path could not be interpreted. WHY? If I set both JAVA_HOME and path as “System Parameter”, it works...


As Tom pointed out, a system parameter is always available, regardless of what user account is logged in. In contrast, a user parameter is only available if that particular account is being used.

With that in mind, if PATH is updated as a sytem parameter (available to all accounts) but it includes JAVA_HOME, which is defined as a user parameter (only available to one account)... Do you see the problem?

13 years ago
Hi,
I am not a beginner. I used java for 3 years.
But I have never made the JDK installation clear in my mind. What a SHAME!!!
I make install JDK and make it works.
I hope people who really truly understand this could help me out.
But I still have some questions:
1. Should path be “User Parameter” or “System Parameter”?
2. Should classpath be “User Parameter” or “System Parameter”?
3. Should JAVA_HOME be “User Parameter” or “System Parameter”?
4. I found if I set JAVA_HOME as “User Parameter” and set path as “System Parameter” (I use JAVA_HOME when setting path). This will not work, which means % JAVA_HOME % in path could not be interpreted. WHY? If I set both JAVA_HOME and path as “System Parameter”, it works.
5. I think Java –version could not be used as a test to see if JDK is installed successfully. I installed 1.6.21 without setting path. When I use java –version, it works but it says 1.6.22. Obviously, this comes from somewhere else in my computer. But if I use javac directly, it doesn’t work. After I set path, javac works.
13 years ago

Tim Holloway wrote:Well, first of all, there are a lot of reasons why writing your own login system is a bad idea no matter how many times people use login pages for sample code in J2EE books.

However, the reason for your confusion is that the "*.xhtml"s are resource filenames and the "*.jsf"s are URL references. Navigation rules are URL-based, not resource-based, so you have to use the URL, not the resource that the URL pulls in.

Finally, the "jsessionid" is generated by the web application server. It's used to bind a server session to a web user when it's uncertain that a cookie can carry the session ID. Without a session ID, you can't have a continuous web conversation, since unlike client/server, there's no long-term connection in place between page requests.

You should ignore the jsessionid. It will be removed by the J2EE URL parsers and it will be added by the container if needed, but there's nothing there that applications can or should be messing around with.


Hi Tim,
Thank you so so much for your clear answer.
I got an article about this: http://randomcoder.com/articles/jsessionid-considered-harmful
Maybe this will also give you some insights.

I think it is really stupid for the server to append the id without noticing me if I like to do that:-)
My understanding is: if cookie is enabled, server will send a cookie including a jsessionid to browser. And after that, every time browser requests for a page, the browser sends the cookie back to tell the server who I am.

But as you said, if cookie is disabled and jsessionid is appended in url, will browser get jsessionid from the url and then send it back to server to tell server who I am? When sending jsessionid back to server, does browser send cookie back to server? Or in other mechanism? If browser sends cookie back, that means browser can still make cookies even he could not accept cookies:-)

Thank you very much! Have a nice day!
Ziyang
13 years ago
JSF
Hi,
Here is my navigation configuration.

My understanding is if I click the sign in button. I will have the url http://XXXXXX/XXX/default.jsf.

But actually I get the following URL when I log in for the first time:
http://XXXXXX/XXX/login.jsf;jsessionid=CEC3FD6EBB4FE3CBBE37AE3322B23051

Why it is login.jsf not default.xhtml? Why I have jsessionid=CEC3FD6EBB4FE3CBBE37AE3322B23051 appended at the end???

I am really very confusing. Thank you very much.
Ziyang
13 years ago
JSF
I wrote a utility class to get resultset:

So that in other class, I can invoke this method to get resultset:


But this does not work, I get SQLException if I invoke next() method on the returned resultset.

I searched the reason, and i think this may be the reason:
Or you can look at CachedRowSet, because ResultSet object is bound with the Statement object. However, CacheRowset is independent and made for passing across layers.

JDBC Tutorail says:

A CachedRowSet classa disconnected rowset that caches its data in memory; not suitable for very large data sets, but an ideal way to provide thin Java clients, such as a Personal Digital Assistant (PDA) or Network Computer (NC), with tabular data


Could somebody explain more to me?
Thanks a lot,
Ziyang
I use sortby in rich:datatable.

How could I get the name of current sorted column in the back beans?

Thanks a lot.

Ziyang
13 years ago
JSF
I'm working on a RichFaces project. And I want to add Seam into the project.
Could somebody give me some guide or resources about how to configure the seam and richfaces?
Thanks a lot.
13 years ago
JSF
I'm working on a RichFaces project. And I want to add Seam into the project.
Could somebody give me some guide or resources about how to configure the seam and richfaces?
Thanks a lot.

Jesper Young wrote:There are some important things to note with the solutions given above:

Garrett's solution, with Arrays.asList() is efficient because it doesn't need to copy the content of the array. This method returns a List that is a "view" onto the array - a wrapper that makes the array look like a list. When you change an element in the list, the element in the original array is also changed. Note that the list is fixed size - if you try to add elements to the list, you'll get an exception.

Ernest's solution: new ArrayList(Arrays.asList(myArray)); copies the content of the array to a new ArrayList. The copy is ofcourse independent of the array, and you can add, remove etc. elements as you like.

Janarthan's solution, with Collections.addAll(myList, myStringArray); is essentially the same as Ernest's solution.

If you only need read access to the array as if it is a List and you don't want to add or remove elements from the list, then use Garrett's solution. Otherwise use Ernest's or Janarthan's solution.



These are great comments.
But I think in most conditions, people will want to make a "static" array to a "dynamic" arraylist.
13 years ago

Janarthan S Sathiamurthy wrote:import java.util.Collections;

List myList = new ArrayList();
String[] myStringArray = new String[] {"Java", "is", "Cool"};

Collections.addAll(myList, myStringArray);

After this code, 'myList' should contain all the elements from the array.

Best regards,
Janarthan S



Good solution!!!
13 years ago
The project was not built due to "A resource exists with a different case: '/MoneyWise/bin/com/moneywise'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent.

Could somebody tell me what I did wrong?

Thanks a lot!!!
13 years ago