Ron McLeod

+ Follow
since Feb 12, 2013
Ron likes ...
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
Merit badge: grant badges
For More
Richmond, BC, Canada
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt Green check
expand Greenhorn Scavenger Hunt

Recent posts by Ron McLeod

Piet Souris wrote:First thought: intstream iterate from size ...

With my case, I don't know the size in-advance, and to discover it, I would need to fully consume the stream.
2 hours ago
I want to be able to transform a stream with zero or more elements into a stream with zero or one elements, where the element is the last element from the original stream.

The code below does work, but I wondering if there might be a better way where I don't need to process each element one-by-one.

3 hours ago

Rajkamal Pillai wrote:My default session timeout value is set to 30 in web.xml, so -

I understand that this is applicable across all user sessions.

Yes - that setting will cause sessions to timeout after 30 minutes of inactivity (unless overridden on a per-session basis using HttpSession#setMaxInactiveInterval after the session has been created).

Rajkamal Pillai wrote:... my issue is that Users are logged off after (the default) 30 seconds.

Does not have any effect at all.

How did you determine this?  In this post I found that HttpSession#setMaxInactiveInterval works as-expected.  I provided the code that I used to prove that it was working as well as test results.  You should be able to use this same code in your environment to test as well.

Rajkamal Pillai wrote:My question is about how to modify the timeout interval dynamically, other than by making changes to web.xml. What worries me is my suggested solution should not cause performance and/or usability side effects.

I'm not really sure what kinds of performance/usabilities issues you might be thinking of.  Can you give some examples?

Rajkamal Pillai wrote:I am on Tomcat 9.0.76
Can you kindly advice what version I should look to upgrade to?

I don't think it matters.  I used 9.0.73 to test with because I already had the docker image downloaded.

The title of this thread is: Tomcat server timeout settings not working as expected..  If you can share some details when/how you are overriding the configured default timeout period, and provide some evidence that it is not working properly, then we can probably help more.
5 days ago
I agree with Tim that this looks like a server-side problem.

I ran basically your same code against and there were no issues.
1 week ago

Rajkamal Pillai wrote:The issue I face is that the value set through does not have appear to have much effect.
Remember reading that the timeout value will be defaulted to the value in web.xml (by a Tomcat process?).

Am I correct and is there any way around this?

I'm really sure where you are at now - after doing some testing, I am going to reply your original question.

Yes, HttpSession#setMaxInactiveInterval does change affect the timeout period for an inactive session.  Running Tomcat version, I observed that the the session will timeout (and be destroyed) sometime after the specified interval.  It appears like with the version of Tomcat that I was running, that a timeout check is performed every 60 seconds, so the actual time when the session is declared invalid can be up to 60 seconds after what you might expect.

Test setup:

Max inactive interval not setMax inactive interval set to 60 (notice how all sessions expire at 55 second mark)Max inactive interval set to 60 (session activity after 21 seconds; created and last accessed different)Max inactive interval set to 120
1 week ago
1 week ago
Your example will not compile because forEach expects to operate on a Consumer, and a Consumer cannot return a value.

If you wrapped it with something like System.out.println like Liutauras showed before it will also fail to compile because variables in a lambda expression need to be effectively final, and positives, zeroes, and negatives are not.
1 week ago

Rajkamal Pillai wrote:The issue I face is that the User is not logged off after the timeout duration.

You should be able to get notifications of expiring sessions by registering a HttpSessionListener.  It will be called just after a session has been created (sessionCreated()), and just before a session is to be invalidated (sessionDestroyed()).
2 weeks ago
Bill - what version of Java are you working with?
I don't know about the Swing side of things, but you can take a look at the saveImageToDatabase and getImageFromDatabaseAsByteArray methods for examples to put and get images with the database.  I don't think you were far off, but you took a wrong turn with ObjectOutputStream.
3 weeks ago and will both take you to the same repository.

kevin Abel wrote:When I look at the chapter information it shows changes to the code, but not the code in the book.

It seems like you are clicking on the wrong link in the repository view.  Try clicking in the link in the Name column rather than the Last Commit column.

For example - at:

Clicking on ch12 will take you to:

And then clicking on will take you to:

3 weeks ago

kevin Abel wrote:I cannot find the post on the forum even after searching a while ...

This one?: Head First Java - Where is the code from the book?
3 weeks ago

Jack Tauson wrote:What I'm trying to do is to send the base64 encoded string to the web browser ...

Why do you want to do that?  Normally you would set the Content-Type to application/pdf, and then stream the binary content of the PDF document to the browser without any transformation.

A browser like Chrome is able to render the document directly; other browsers may launch an application such as Acrobat to perform the rendering.
4 weeks ago