Mukesh Negi

Greenhorn
+ Follow
since Jul 25, 2012
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mukesh Negi

Henry Wong wrote:


Oops... my mistake. I meant the SO_KEEPALIVE socket option. Using this option, on a TCP socket, *should* enable checking at the switches for packets (or KA packets), and reset the socket when they timeout.

Regardless, as already mentioned, with the large mix of hardware (and network hops), this feature is not guaranteed to work in all cases. And if you want that guarantee, you will have to implement it into your protocol.

Sorry for the confusion,
Henry



Henry really thanks for your reply. Above, you have mentioned about SO_KEEPALIVE option, which is used to keep connection alive.

Henry, but I don't want to keep it alive. I want to break the write operation after specified time. The second thing you mentioned is about hardware, again same thing implies here as well. I just want to break the write after specified time.

Actually, I am using org.apache.commons.net.ftp api to deal with file uploading and downloading. And I am looking for the solution while uploading the file.
Thanks for your replies..

According to my understanding SO_TIMEOUT is considered only when we are reading from the socket, I have tried this and it worked. The time_out parameter that we give in socket.connect method is the time_out only when establishing the connection.
I am more concern about when writing to the socket. I have read some where that write does not blocks but read does blocks.

My understanding on socket.write is following, please correct me if wrong:
When writing to socket it completely depends on the TCP buffer, I mean, if we are writing a small amount of data, then it will immediately wait on socket.read to read the acknowledgement and here SO_TIMEOUT will come into picture. This is so because we have completely written data to the buffer and hence our write operation is completed. But this is not the case with large data as our write operation does not get completed.
If while writing to the socket's output stream, the peer closes the connection (or because of some reason the connectivity is loosed), will my program wait infinitely or will it timeout after certain amount of time.

I searched a lot, but unable to find the answer.
thanks for all your replies. Actually, their were no issues. It is the C3P0 which makes a timer for each datasource object created and therefore I was getting extra Timer threads.
Even if its currently working correctly without any problem, in threading its not guarented in future, as i have coded considring 1 thread/timer. But if its wrong it may give unwanted result. I am using other apis i.e log4j for loging and c3p0 for connection pooling. I have found that c3p0 uses a timer. Thanks 4 your reply..
Hi....
I am using java.util.Timer in my code. I have two Timer. 1st runs after each 10 seconds and the other after each 6 hours. When I check the no. of threads in the jconsole its showing 4 threads for timer.
Actually I am not getting why its showing so. I dont want multiple threads for a single Timer to start as it can corrupt my data.
I have googled it a lot, as per my understanding it dosent start different threads to complete the tasks. It keeps the pending tasks in the queue.
But I am not getting why jconsole is showing it.
Please help me....

Thanks in advance.
@Howard @Farhan: I did the same thing without using transactional apprach, and it worked. I used MySql.

According to its documentation the last generated key is stored by the db system for each connection seperately.

I am not getting, why in case of Farhan it was not working.

Do any one know any specific reason why it dint worked, so tha I can correct myseslf..

Thanks.
@Tim that means if anyone gets the sessionid by any mean, can have all privileges of the sessionid until the respective session is destroyed.

Please correct me.

If anyone can provide me any resource where i can understand session in depth with its security aspects.

Thanks
11 years ago
@farhan: I'l stick to my above post. This will serve your purpose.
You first insert into your main table where there is auto increment value.

Than by using the following code you will be getting last inserted key. i.e., your last auto incerement value as database system stores the last key value inserted.

ResultSet rs = stmt.getGeneratedKeys();
if (rs.next()){
yourKey = rs.getInt(1);
}

After getting the auto increment value you can insert it into the tables where it is the foreign key.

Hope this will help you.
@farhan: Use the following code.

Statement stmt = db.prepareStatement("your query", Statement.RETURN_GENERATED_KEYS);

stmt.executeUpdate();

ResultSet rs = stmt.getGeneratedKeys();
if (rs.next()){
yourKey = rs.getInt(1);
}


@Jatan: So if we get session id through cookie than any one who wants to do mischief can use this session id.
11 years ago

Anirudh Srivastav wrote:Vinayak

Hope this http://stackoverflow.com/questions/3106452/how-do-servlets-work-instantiation-session-variables-and-multithreading helps you!

Would like to know experts view from Bear as well.




Hi @Anirudh, in the above link I found

The webapp's web.xml will be parsed and every Servlet, Filter and Listener found in web.xml will be created once and kept in server's memory as well. When the servletcontainer shuts down, it will unload all webapplications and the ServletContext and all Servlet, Filter and Listener instances will be trashed



But I have read that Servlets are loaded and Intsantiated when the request for that specific Servlet comes.

Please correct me if I am wrong.

Thanks
11 years ago
I have one question, How is session id sent to client side. Is it stored in cookies?
11 years ago

Aditi Joshi wrote:Hi,

Can anyone help me in displaying employee details after i enter emp_id in first text box.

And employee details should come in other text boxes on same jsp page.

Thanks in advance.



Hi Aditi. You can do it using JSP as well. But you have to first decide wheather you have to send the request synchronously or asynchronously(using ajax).

If you decide to send synchronously you can send request to the same jsp file and depending on some condition you can show the details of the employee.

But I'l suggest you to send it asynchronously using Ajax.
11 years ago
JSP
I have one question, How is session id sent to client side. Is it stored in cookies?
11 years ago