wood burning stoves 2.0*
The moose likes Servlets and the fly likes call a servlet/Filter during refresh ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "call a servlet/Filter during refresh ?" Watch "call a servlet/Filter during refresh ?" New topic
Author

call a servlet/Filter during refresh ?

agustinus lumbantoruan
Ranch Hand

Joined: Jul 17, 2010
Posts: 56
Dear Java Servlet Programmers

I would like to know if it is possible to call a servlet when we refresh a JSP page. Usually we call a servlet from a <a href> and form. But now, how can we call a servlet through the same URL or a refresh page

For example, the users is already logged in and browse at my profile page for couple of minutes.
Then the users want to refresh that page because he/she just feels like to do it. When the users press the refresh button, it will call a servlet named "ProfileServlet.java" or perhaps call a Filter instead going directly the JSP page.

I aksed this because, I am facing a problem with my session Time out. For every 20 minutes, I refresh a page. It always gies me this irritating 500 HTTP error message. I guess the problem is in the session time out.
Recently I have google the problem, but most of the respond said that I must use a Filter.

So again, how can I call a servlet or Filter by refreshing a page instead calling the JSP page.
Is there any posibility this could be achieve or perhaps another cool alternative solution

Please advice/assist. I really appreciate your time and help. God Bless =)



----------
Love Java Programming
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

agustinus lumbantoruan wrote:I aksed this because, I am facing a problem with my session Time out. For every 20 minutes, I refresh a page. It always gies me this irritating 500 HTTP error message. I guess the problem is in the session time out.
Recently I have google the problem, but most of the respond said that I must use a Filter.

You should find the actual cause before you start getting creative.
Which site recommend a filter? without knowing what they say or why they say or why they say it, it is hard for us to comment.

That said, if you use a FrontController then all requests get sent to a single Servlet and you can always use that location to determine the next course of action.
agustinus lumbantoruan
Ranch Hand

Joined: Jul 17, 2010
Posts: 56
David O'Meara wrote:
agustinus lumbantoruan wrote:I aksed this because, I am facing a problem with my session Time out. For every 20 minutes, I refresh a page. It always gies me this irritating 500 HTTP error message. I guess the problem is in the session time out.
Recently I have google the problem, but most of the respond said that I must use a Filter.

You should find the actual cause before you start getting creative.
Which site recommend a filter? without knowing what they say or why they say or why they say it, it is hard for us to comment.

That said, if you use a FrontController then all requests get sent to a single Servlet and you can always use that location to determine the next course of action.


Thank your for the reply David

Ohh about the websites I visited were

http://www.coderanch.com/t/502600/Servlets/java/Checking-Session-Timeout#2268191
Somewhere in the middle of the forum Steve Dyke responded a filter and wrote a code.

http://java.sun.com/products/servlet/Filters.html
It mentions Authentication-Blocking requests based on user identity.
Logging and auditing-Tracking users of a web application.


http://www.java2s.com/Code/Java/Servlets/Servletsessionfilter.htm

http://forums.sun.com/thread.jspa?threadID=5405983
He mentions request.getHeader("refresh");

So about FrontController... Interesting... I will google that.

Edit:
From what I red about FrontController in the internet. It sounds like a Filter. hmmm

Thanks man.


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

It "sort of" a filter, and could be implemented as one, but usually it's a servlet that dispatches to unit of execution.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138
Is it the necessary/suggested way to use Filter for this purpose... I mean we can also log the timeout using logger and sent it to login page saying session expired, please log in again!, if session time out by checking it in servlet code during each request.

Please share your opinions.

Thanks,

Rahul

agustinus lumbantoruan
Ranch Hand

Joined: Jul 17, 2010
Posts: 56
Rahul Nair wrote:Is it the necessary/suggested way to use Filter for this purpose... I mean we can also log the timeout using logger and sent it to login page saying session expired, please log in again!, if session time out by checking it in servlet code during each request.

Please share your opinions.

Thanks,

Rahul



Sorry Rahul I replied late. =)

Yeah you are right about
We can log the timeout using logger and sent it to login page saying session expired

Do you know how to log the timeout? That would be really interesting, because creating a log timeout would be very useful for the administrator.\

Thanks for sharing idea. Looking forward to your reply

agustinus lumbantoruan
Ranch Hand

Joined: Jul 17, 2010
Posts: 56
Sorry double post
Rahul Nair
Ranch Hand

Joined: Dec 01, 2007
Posts: 138


Do you know how to log the timeout? That would be really interesting, because creating a log timeout would be very useful for the administrator.\

Thanks for sharing idea. Looking forward to your reply


You can use the log4j for logging, so that administrator can use it to check the details...
Please check here for more details.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: call a servlet/Filter during refresh ?
 
Similar Threads
automatic refreshing
User who is logged in simultaneously from different browser ... how to forcely logout the first user
Creating a custom scope... (kinda long)
Problem with session timeout
LockTimedOutException