• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

call a servlet/Filter during refresh ?

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

https://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.


 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry double post
 
Rahul Nair
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
A timing clock, fuse wire, high explosives and a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic