<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" > <channel><title>Comments on: Tutorial: HTTP Session handling using Servlet Filters</title> <atom:link href="http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/feed" rel="self" type="application/rss+xml" /><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html</link> <description>Tutorials, Java, J2EE, Struts, AJAX, JavaScript, CSS, Web 2.0, MySQL, Articles</description> <lastBuildDate>Thu, 09 Feb 2012 07:08:35 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Chripin</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-16058</link> <dc:creator>Chripin</dc:creator> <pubDate>Mon, 19 Sep 2011 12:22:04 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-16058</guid> <description>@Gisli I am getting the same problem. But when i use tomcat v6 i don&#039;t get the problem. My problem is that the values i place in the session are lost. If you find the solution please update me.</description> <content:encoded><![CDATA[<p>@Gisli I am getting the same problem. But when i use tomcat v6 i don&#8217;t get the problem.<br /> My problem is that the values i place in the session are lost.<br /> If you find the solution please update me.</p> ]]></content:encoded> </item> <item><title>By: Gisli</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-15993</link> <dc:creator>Gisli</dc:creator> <pubDate>Thu, 08 Sep 2011 17:46:30 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-15993</guid> <description>I&#039;m basically getting the same error as &quot;learner&quot;. I didn&#039;t use this code but rather wrote my own. I have discovered that if I call getSession()/getSession(true), I always geta brand new session. If I call getSession(false) I always get null. I&#039;ve been tearing my hair out over this the past few days. If I set session attributes in the filter and check them in the page where the filter redirects me to, I can read the values. But if I set attributes in the page, the filter never sees them because, as I said, getSession either returns null or a brand new session.I&#039;m using Tomcat 7.0.2. I&#039;ve been using basic JSPs for years but this is the first time I create a servlet filter. I thought it was so brilliant until I hit this wall.Hope you can help me. I would post the code but don&#039;t have access to it right now.</description> <content:encoded><![CDATA[<p>I&#8217;m basically getting the same error as &#8220;learner&#8221;. I didn&#8217;t use this code but rather wrote my own. I have discovered that if I call getSession()/getSession(true), I always geta brand new session. If I call getSession(false) I always get null. I&#8217;ve been tearing my hair out over this the past few days. If I set session attributes in the filter and check them in the page where the filter redirects me to, I can read the values. But if I set attributes in the page, the filter never sees them because, as I said, getSession either returns null or a brand new session.</p><p>I&#8217;m using Tomcat 7.0.2. I&#8217;ve been using basic JSPs for years but this is the first time I create a servlet filter. I thought it was so brilliant until I hit this wall.</p><p>Hope you can help me. I would post the code but don&#8217;t have access to it right now.</p> ]]></content:encoded> </item> <item><title>By: Sandeep</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-15751</link> <dc:creator>Sandeep</dc:creator> <pubDate>Mon, 22 Aug 2011 14:13:50 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-15751</guid> <description>Hi, I&#039;m developing a web application using JSP. In my application, after user login, if he clicks back button of the browser, he should not go to the index page of my website. can u help me with this?</description> <content:encoded><![CDATA[<p>Hi, I&#8217;m developing a web application using JSP. In my application, after user login, if he clicks back button of the browser, he should not go to the index page of my website. can u help me with this?</p> ]]></content:encoded> </item> <item><title>By: learner</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-14397</link> <dc:creator>learner</dc:creator> <pubDate>Wed, 23 Mar 2011 12:03:13 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-14397</guid> <description>Hi I keep on getting The page isn&#039;t redirecting properly error, any ideas?thanks</description> <content:encoded><![CDATA[<p>Hi I keep on getting The page isn&#8217;t redirecting properly error, any ideas?</p><p>thanks</p> ]]></content:encoded> </item> <item><title>By: Alex Vicente Chacón Jiménez</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-14063</link> <dc:creator>Alex Vicente Chacón Jiménez</dc:creator> <pubDate>Sun, 20 Feb 2011 16:32:38 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-14063</guid> <description>Thank you very much for this article. But I improved the example in the following way: &lt;pre&gt; public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String url = request.getServletPath(); if (urlList.contains(url)) { chain.doFilter(req, res); } else { HttpSession session = request.getSession(false); if (session == null ) { response.sendRedirect(request.getContextPath()); } else { chain.doFilter(req, res); } } } &lt;/pre&gt; This code prevent a java.lang.IllegalStateException: Cannot forward after response has been committed</description> <content:encoded><![CDATA[<p>Thank you very much for this article.<br /> But I improved the example in the following way:</p><pre>
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException
	{

		HttpServletRequest request = (HttpServletRequest) req;
		HttpServletResponse response = (HttpServletResponse) res;
		String url = request.getServletPath();

		if (urlList.contains(url))
		{
			chain.doFilter(req, res);
		}
		else
		{
			HttpSession session = request.getSession(false);

			if (session == null )
			{
				response.sendRedirect(request.getContextPath());
			}
			else
			{
				chain.doFilter(req, res);
			}
		}
	}
</pre><p>This code prevent a java.lang.IllegalStateException: Cannot forward after response has been committed</p> ]]></content:encoded> </item> <item><title>By: raju</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-13516</link> <dc:creator>raju</dc:creator> <pubDate>Mon, 06 Dec 2010 18:23:57 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-13516</guid> <description>wrt a prg html page(login.html) which accept username and password.Authenticaticate them using filters and then to helloworld servlet  if the user is a valid .(if username is &quot;genesis&quot; print  response as &quot;hello&quot; ,otherwise print response as &quot;invaliduser&quot; )...............answer give me</description> <content:encoded><![CDATA[<p>wrt a prg html page(login.html) which accept username and password.Authenticaticate them using filters and then to helloworld servlet  if the user is a valid .(if username is &#8220;genesis&#8221; print  response as &#8220;hello&#8221; ,otherwise print response as &#8220;invaliduser&#8221; )&#8230;&#8230;&#8230;&#8230;&#8230;</p><p>answer give me</p> ]]></content:encoded> </item> <item><title>By: sai</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-12722</link> <dc:creator>sai</dc:creator> <pubDate>Thu, 24 Jun 2010 04:09:30 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-12722</guid> <description>Hi,how can use this for ajax applications. per say, i have extjs spring applications. need to handle session time out or if session is not their, redirect to different page..</description> <content:encoded><![CDATA[<p>Hi,</p><p>how can use this for ajax applications. per say, i have extjs spring applications. need to handle session time out or if session is not their, redirect to different page..</p> ]]></content:encoded> </item> <item><title>By: Nageswar</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-12665</link> <dc:creator>Nageswar</dc:creator> <pubDate>Thu, 10 Jun 2010 17:28:27 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-12665</guid> <description>Hi I am getting StringTokenizer null pointer error, i Tried but same thing is comming. if you have any solution plz send meString urls = filterConfig.getInitParameter(&quot;avoid-urls&quot;); StringTokenizer token = new StringTokenizer(urls, &quot;,&quot;); urlList = new ArrayList(); while (token.hasMoreElements()) { urlList.add(token.nextToken()); } totalURLS = urlList.size();</description> <content:encoded><![CDATA[<p>Hi I am getting StringTokenizer null pointer error, i Tried but same thing is comming.<br /> if you have any solution plz send me</p><p> String urls = filterConfig.getInitParameter(&#8220;avoid-urls&#8221;);<br /> StringTokenizer token = new StringTokenizer(urls, &#8220;,&#8221;);<br /> urlList = new ArrayList();<br /> while (token.hasMoreElements()) {<br /> urlList.add(token.nextToken());<br /> }<br /> totalURLS = urlList.size();</p> ]]></content:encoded> </item> <item><title>By: Viral Patel</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-12187</link> <dc:creator>Viral Patel</dc:creator> <pubDate>Tue, 23 Feb 2010 18:41:35 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-12187</guid> <description>@Chandra: The above example will work for you in any case. i.e. it will work for JSPs, Servlets or Struts2 as well. Filters are available for both servlets and JSPs because we have mapped /* url with filter SessionFilter.</description> <content:encoded><![CDATA[<p>@Chandra: The above example will work for you in any case. i.e. it will work for JSPs, Servlets or Struts2 as well. Filters are available for both servlets and JSPs because we have mapped /* url with filter SessionFilter.</p> ]]></content:encoded> </item> <item><title>By: Chandra</title><link>http://viralpatel.net/blogs/2009/02/http-session-handling-tutorial-using-servlet-filters-session-error-filter-servlet-filter.html/comment-page-1#comment-12186</link> <dc:creator>Chandra</dc:creator> <pubDate>Tue, 23 Feb 2010 17:53:16 +0000</pubDate> <guid isPermaLink="false">http://viralpatel.net/blogs/?p=798#comment-12186</guid> <description>Hi Viral,Can we do the same thing..i.e when user copy paste the URL in new window, he must be redirected to Login page using JSPs. I am using Struts 2.0 framework. I am not using servlets. Filters are available for servlets only or for JSPs also?TIA</description> <content:encoded><![CDATA[<p>Hi Viral,</p><p>Can we do the same thing..i.e when user copy paste the URL in new window, he must be redirected to Login page using JSPs. I am using Struts 2.0 framework. I am not using servlets. Filters are available for servlets only or for JSPs also?</p><p>TIA</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: viralpatel.net @ 2012-02-09 14:27:05 -->
