• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

call a servlet/Filter during refresh ?

 
agustinus lumbantoruan
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It "sort of" a filter, and could be implemented as one, but usually it's a servlet that dispatches to unit of execution.
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry double post
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic