Manimekala Velautham

Greenhorn
+ Follow
since May 31, 2006
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 Manimekala Velautham

In Linux box, I am able to run the following curl command to send data in content of the http post request to my servlet.

curl -k -X POST -T postdat "http://localhost:8084/Test/Test"

Content of postdata is
myVar=abc&id=12345

I don�t know how to do the same with html program.

Any help on this appreciated.
Hi,

This is a servlet application. It has some HashMaps in memory, which contains key value pairs. These HashMaps are updated at every 1 hour by a thread. The servlet requests(https) will have the 'key' as query string and to fetch value from the hashmaps. The response will have the 'value'in XML format.

For the above logic, I have 3 Java Classses
1. QueryMap.java SERVLET CLASS
2. Manager.java JAVA CLASS
3. MapMonitor.java JAVA THREAD CLASS
Manager.java
-------------

In the above code,

the method processRequest() will be called by the servlet for each and every request to take the value from the hash map for the key requested.

the method addHashMap() will be called by the thread by every 1 hour to update or to place the new hashmaps in manager class. (maps are not going to be removed in this application)

My need is, If any request is processing, this thread has to wait for the processRequest method to complete. Same way, if the addHashMap() method is progress, the processRequest method has to wait utill it completes.

This code is working fine, but I am not able to figure out is there any problem of dead locks or other issues. Please review this code and suggest me whether my approah is correct or not.

Thanks
[/CODE]
Hi, Thanks for your suggestions. I understood the purpose of wait() and notify().

In this, when the the processRequest method is in progress, I dont want to add anything to to myList shared variable. The Thread which is adding a new value or changes the value in particular index in myList should wait for the processRequest method to complete.

Same way, when the thread that is executing the addValue method is in progress on the myList variable, I want the requests to wait till the thread comes out from the addValue method.
Hi,

I have one Java class and it is a singleton class. I have one thread and one servlet.

The Java class has a
1. global variable called "myList" of type ArrayList to hold Hashmaps.
2. method addListValues()- Called by the thread every 1 hr to add a HashMap to the myList.
3. method processRequest()- Called by Servlet Requests to read the value from the myList to serve the requests.

In order to protect cuncurrent access to this myList variable, I have introduced synchronized blocks in the above methods. See the code below. Will this approach solve my problem?...Please help me with your views.

Thanks for your suggestions.

Yes.The Application requires a collection object that maps keys to values.
It is a servlet application, which will have one collection object as a in memory database. The requests to this servlet will have the key to get the value. The response is a xml file with the corresponding value. The keys and values all are String objects. It is a ramdom search. This collection object should be recreated at specified intervals by reading a text file which will have the keys and values comma separated.
12 years ago
I want to have a HashTable or a HashMap or some other Collection object in my application. I am not able to decide which collection object will meet my requirements. Can anyone please help me which collection construct can I use?

The Considerations are,
1.Should be readale as fast as possible
2.It should able to grow(upto 1 million or more) and not slow down the search process.
3. Should be thread safe.
12 years ago
Hi

I want to sort a Hashtable's values in alphabetical,with duplicates and in case_insensitive manner. I tried the following code. Please take a look.



With the above code I got the values in the Hashtable alphabetically,with duplicates and in case_insensitive manner. Now I want to have corresponding keys also. How to do this?

Any help is appreciated.

Thanks
Manimekala
12 years ago
Yeah...I forgot to think this way...this fixed my problem and is working fine. Thanks
12 years ago
JSP
I have a jsp page, there I want to execute the following shell script with the exit codes for 0 and 1 for success and fail respectively thru Runtime.getRuntime().exec().



The exection is success while execting the shell script alone and also thru a stand alone Java program. But While calling this shell script from the JSP, I am always getting the negative response, that is the Process.exitValue() returns always 1.

Any suggestions and help appreciated !!!
12 years ago
JSP
Oh ok.Thanks for your comments.Ya thru JNI it is working fine. I have checked. But for my codebase, it is better to use the Runtime.exec instead of JNI.
13 years ago
Is there anyway to get the uid and group id's of unix from a java program without using Runtime.getRuntime().exec() ?
13 years ago
Hi,

I dropped the idea of doing that in java and I fixed that issue by keeping one more JNI call to set the Locale.

Thank you so much for spending your valuable time in this issue....
Timely Help...Thanks.
13 years ago
As per my codebase,writing one more native method will also cause problem,Is there any way to solve this problem in java itself?..
13 years ago
Thanks.
I have tried and it is working fine though the Locale is set to ja_JP.eucJP. But i want to do that from java. Is it possible?...Because, my native methods are shared my many applications.
13 years ago
Hi
Thanks for your valuable suggestion.

My problem is

I am using JNI for writing logs.
When the locale is set to ja_JP.eucJP, JNI call for writing a syserrlog is printing some japanese characters instead of "Sep" in Timestamp.

If I run a standalone C program to print the date, it is printing in english though the locale is set to ja_JP.eucJP.

When you call the same C function to print the date through JNI, it is printing some junk chars for "Sep".So i want to change the locale "C" from my java program.

I tried Locale.setDefaultLocale(Locale.English)...but still my JNI call is printing some junk chars for "Sep". So i tried by changing the LC_ALL from java program with exec().

Java Code:


C Code:
13 years ago