<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>s2sgateway &#187; Java</title>
	<atom:link href="http://s2sgateway.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://s2sgateway.com</link>
	<description>Practical Learning of Programming languages such us j2ee,java,jsp</description>
	<lastBuildDate>Sat, 21 Jan 2012 18:55:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>java.sql.SQLException: General error solution</title>
		<link>http://s2sgateway.com/java/java-sql-sqlexception-general-error-solution/</link>
		<comments>http://s2sgateway.com/java/java-sql-sqlexception-general-error-solution/#comments</comments>
		<pubDate>Sat, 18 Sep 2010 03:59:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[datasource error]]></category>
		<category><![CDATA[driver for msaccess in java]]></category>
		<category><![CDATA[dsn error]]></category>
		<category><![CDATA[how to create a datasource]]></category>
		<category><![CDATA[how to create the odbc dsn]]></category>
		<category><![CDATA[java errors and solutions]]></category>
		<category><![CDATA[java general exception]]></category>
		<category><![CDATA[java.sql.SQLException: General error solution]]></category>
		<category><![CDATA[main class not found error in java]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=727</guid>
		<description><![CDATA[java.sql.SQLException: General error solution is a post from: s2sgateway<p><a href="http://s2sgateway.com/java/java-sql-sqlexception-general-error-solution/">java.sql.SQLException: General error solution</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[java.sql.SQLException: General error solution is a post from: s2sgateway<p><a href="http://s2sgateway.com/java/java-sql-sqlexception-general-error-solution/">java.sql.SQLException: General error solution</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/java/java-sql-sqlexception-general-error-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert jar to exe file</title>
		<link>http://s2sgateway.com/java/convert-jar-to-exe-file/</link>
		<comments>http://s2sgateway.com/java/convert-jar-to-exe-file/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 18:51:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[convert jar to exe file easily]]></category>
		<category><![CDATA[how to create a exe file using software]]></category>
		<category><![CDATA[how to create a war file]]></category>
		<category><![CDATA[how to create exe in java]]></category>
		<category><![CDATA[how to create jar file in java]]></category>
		<category><![CDATA[jar to exe converter]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=552</guid>
		<description><![CDATA[Convert jar to exe file is a post from: s2sgateway<p><a href="http://s2sgateway.com/java/convert-jar-to-exe-file/">Convert jar to exe file</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[Convert jar to exe file is a post from: s2sgateway<p><a href="http://s2sgateway.com/java/convert-jar-to-exe-file/">Convert jar to exe file</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/java/convert-jar-to-exe-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to extract war file in java</title>
		<link>http://s2sgateway.com/jsp/how-to-extract-war-file-in-java/</link>
		<comments>http://s2sgateway.com/jsp/how-to-extract-war-file-in-java/#comments</comments>
		<pubDate>Mon, 31 May 2010 12:02:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[creating web archive files]]></category>
		<category><![CDATA[deploying webarchive files]]></category>
		<category><![CDATA[extract war file in java]]></category>
		<category><![CDATA[extract war file in jsp]]></category>
		<category><![CDATA[how to extract a war file]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=447</guid>
		<description><![CDATA[How to extract war file in java is a post from: s2sgateway<p><a href="http://s2sgateway.com/jsp/how-to-extract-war-file-in-java/">How to extract war file in java</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[How to extract war file in java is a post from: s2sgateway<p><a href="http://s2sgateway.com/jsp/how-to-extract-war-file-in-java/">How to extract war file in java</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/jsp/how-to-extract-war-file-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Students management java project download</title>
		<link>http://s2sgateway.com/projects-download/students-management-java-project-download/</link>
		<comments>http://s2sgateway.com/projects-download/students-management-java-project-download/#comments</comments>
		<pubDate>Sun, 23 May 2010 14:13:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[projects download]]></category>
		<category><![CDATA[Student Projects]]></category>
		<category><![CDATA[free j2ee projects]]></category>
		<category><![CDATA[free java projects]]></category>
		<category><![CDATA[free jsp projects]]></category>
		<category><![CDATA[java projects download]]></category>
		<category><![CDATA[mca projects in java]]></category>
		<category><![CDATA[mini projects in java]]></category>
		<category><![CDATA[projects in java]]></category>
		<category><![CDATA[student projects in java]]></category>
		<category><![CDATA[Students management java project download]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=445</guid>
		<description><![CDATA[Students management java project download is a post from: s2sgateway<p><a href="http://s2sgateway.com/projects-download/students-management-java-project-download/">Students management java project download</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[Students management java project download is a post from: s2sgateway<p><a href="http://s2sgateway.com/projects-download/students-management-java-project-download/">Students management java project download</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/projects-download/students-management-java-project-download/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>compare current time with database retrieved time in jsp</title>
		<link>http://s2sgateway.com/jsp/compare-current-time-with-database-retrieved-time-in-jsp/</link>
		<comments>http://s2sgateway.com/jsp/compare-current-time-with-database-retrieved-time-in-jsp/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 10:44:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[compare current time with database retrieved time in jsp]]></category>
		<category><![CDATA[current date and time in java]]></category>
		<category><![CDATA[current date in jsp]]></category>
		<category><![CDATA[current time in java]]></category>
		<category><![CDATA[date and time in jsp]]></category>
		<category><![CDATA[split in java]]></category>
		<category><![CDATA[split in jsp]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=413</guid>
		<description><![CDATA[This is the viewer question asked by smiten. how can i compare the database stored time to current time? I had previously written an article about how to display time in jspNow just make some changes retrieve the database time and split the values of hours,minutes,seconds and finally check the values to get the real [...]<p><a href="http://s2sgateway.com/jsp/compare-current-time-with-database-retrieved-time-in-jsp/">compare current time with database retrieved time in jsp</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is the viewer question asked by smiten.<br />
how can i compare the database stored time to current time?<br />
I had previously written an article about <a href="http://s2sgateway.com/?p=290">how to display time in jsp</a>Now just make some changes retrieve the database time and split the values of hours,minutes,seconds and finally check the values to get the real time.</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:520px;max-width:520px;height:150px;text-align:left;overflow:auto"><code>
<pre>
&lt;%@ page language="java" import="java.util.*,java.sql.*,java.math.*,java.text.SimpleDateFormat"pageEncoding="ISO-8859-1"%&gt;
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
String date=dateFormat.format(calendar.getTime());
String c="select * from time";
	st1=con.createStatement();
	ResultSet rs1=st1.executeQuery(c);
	while(rs1.next())
	{
dbdate=rs1.getString(5);
}
 String[] exdate=a.split("-");
	 int dbdate=Integer.parseInt(dbexdate[0]);
	 String[] currentdate=date.split("-");
	 int cdate=Integer.parseInt(currentdate[0]);

 if(dbenddate[1].equals(currentdate[1]))
			 {
	 diff=dbdate-cdate;
			 }
out.println(diff);
%&gt;
</pre>
<p></code></pre>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-0609065187474065";
/* post link adds for s2s */
google_ad_slot = "4731489867";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Have a doubt leave a comment,Happy coding</p>
<p><a href="http://s2sgateway.com/jsp/compare-current-time-with-database-retrieved-time-in-jsp/">compare current time with database retrieved time in jsp</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/jsp/compare-current-time-with-database-retrieved-time-in-jsp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>captcha project in jsp/servlet</title>
		<link>http://s2sgateway.com/jsp/captcha-project-in-jspservlet/</link>
		<comments>http://s2sgateway.com/jsp/captcha-project-in-jspservlet/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 14:06:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[captcha creation]]></category>
		<category><![CDATA[J2EE codes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[capcha project in jsp]]></category>
		<category><![CDATA[captcha full code]]></category>
		<category><![CDATA[captcha in jsp form]]></category>
		<category><![CDATA[captcha using servlet]]></category>
		<category><![CDATA[create capcha in jsp]]></category>
		<category><![CDATA[create captcha using j2ee]]></category>
		<category><![CDATA[create random image using jsp]]></category>
		<category><![CDATA[how to create a captcha in jsp]]></category>
		<category><![CDATA[how to create random image using servlet]]></category>
		<category><![CDATA[how to use catcha in forms]]></category>
		<category><![CDATA[pagination in jsp]]></category>
		<category><![CDATA[stop spam using captcha]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=407</guid>
		<description><![CDATA[Already i wrote a post about creating random image using servlet that is loacted here http://s2sgateway.com/?p=378,With the continuation here i give you complete code for creating captcha to validate a form to differentiate/protect from robots and spams .In this project i had placed one form page for submitting information with two servlets one for creating [...]<p><a href="http://s2sgateway.com/jsp/captcha-project-in-jspservlet/">captcha project in jsp/servlet</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Already i wrote a post about creating random image using servlet that is loacted here <a href="http://s2sgateway.com/?p=378">http://s2sgateway.com/?p=378</a>,With the continuation here i give you complete code for<br />
<h3>creating captcha to validate a form to differentiate/protect from robots and spams</h3>
<p>.In this project i had placed one form page for submitting information with two servlets one for creating captcha and another for checking the captcha and a result page for showing the result.</h3>
<p>.<br />
<script type="text/javascript">
<!--
google_ad_client = "pub-0609065187474065";
/* post link adds for s2s */
google_ad_slot = "4731489867";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
</br></p>
<p>First create a simple form like below</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:420px;max-width:420px;height:120px;text-align:left;overflow:auto"><code>
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html" charset=UTF-8?&gt;
&lt;title&gt;Captcha Project from www.s2sgateway.com&gt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
&lt;form method="post" action="checkCaptcha.do"&gt;
&lt;table cellspacing="15?&gt;
&lt;tr&gt;
&lt;td align="center"&gt;
&lt;img src="CaptchaServlet.do"&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;input type="text" name="code"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;input type="submit" value="submit"&gt;
&lt;/form&gt;
&lt;br&gt;
&lt;br&gt;&gt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p></code></pre>
</div>
<p>create web.xml file for necessary servlet entry</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:420px;max-width:420px;height:120px;text-align:left;overflow:auto"><code>
<pre>
&lt;web-app&gt;
&lt;servlet&gt;
&lt;servlet-name&gt;CaptchaServlet&gt;/servlet-name&gt;
&lt;servlet-class&gt;
CaptchaServlet
&lt;/servlet-class&gt;
&lt;/servlet&gt;
&lt;servlet&gt;
&lt;servlet-name&gt;CheckCaptcha&gt;/servlet-name&gt;
&lt;servlet-class&gt;
CheckCaptcha
&lt;/servlet-class&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
&lt;servlet-name&gt;CaptchaServlet&gt;/servlet-name&gt;
&lt;url-pattern&gt;/CaptchaServlet.do&gt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;servlet-mapping&gt;
&lt;servlet-name&gt;CheckCaptcha&gt;/servlet-name&gt;
&lt;url-pattern&gt;/checkCaptcha.do&gt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;welcome-file-list&gt;
&lt;welcome-file&gt;index.jsp&gt;/welcome-file&gt;
&lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
<p></code></pre>
</div>
<p>now create the servlet which produces random image&gt;br&gt;</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:420px;max-width:420px;height:120px;text-align:left;overflow:auto"><code>
<pre>
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class CaptchaServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
final int width = 200;
final int height = 50;
char data[][] = new char[1][];
data[0] = getRandomNumber(8).toCharArray();
final BufferedImage bufferedImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
final Graphics2D g2d = bufferedImage.createGraphics();
final Font font = new Font("verdana", Font.BOLD, 18);
RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
renderingHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHints(renderingHints);
g2d.setFont(font);
g2d.setColor(new Color(255, 255, 0));
final GradientPaint gradientPaint = new GradientPaint(0, 0, Color.white, 0, height / 2,
Color.white, true);
g2d.setPaint(gradientPaint);
g2d.fillRect(0, 0, width, height);
g2d.setColor(new Color(255, 155, 0));
Random random = new Random();
final String captcha = String.copyValueOf(data[0]);
request.getSession().setAttribute("captcha", captcha);
int xCordinate = 0;
int yCordinate = 0;
for (int i = 0; i &gt; data[0].length; i++) {
xCordinate += 10 + (Math.abs(random.nextInt()) % 15);
if (xCordinate &gt;= width - 5) {
xCordinate = 0;
}
yCordinate = 20 + Math.abs(random.nextInt()) % 20;
g2d.drawChars(data[0], i, 1, xCordinate, yCordinate);
}
g2d.dispose();
response.setContentType("image/png");
final OutputStream outputStream = response.getOutputStream();
ImageIO.write(bufferedImage, "png", outputStream);
outputStream.close();
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
public static String getRandomNumber(int length) {
String chars = "www.s2sgateway.comabcdefghjijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789";
Random random = new Random();
char[] buf = new char[length];
for (int i = 0; i &gt; length; i++) {
buf[i] = chars.charAt(random.nextInt(chars.length()));
}
return new String(buf);
}
}
</pre>
<p></code></pre>
</div>
<p>Now for checking the image servlet you can write the servlet code as follows&gt;br&gt;</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:420px;max-width:420px;height:120px;text-align:left;overflow:auto"><code>
<pre>

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class CheckCaptcha extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
final String captcha = (String) request.getSession().getAttribute("captcha");
final String code = (String) request.getParameter("code");
if (captcha != null &#038;&#038; code != null) {
if (captcha.equals(code)) {
request.setAttribute("result",
"Congratulations, You Passed The Captcha Test");
} else {
request.setAttribute("result",
"Sorry, You Failed The Captcha Test");
}
request.getRequestDispatcher("/result.jsp").forward(request,
response);
}
}
}
</pre>
<p></code></pre>
</div>
<p>Finally write the code in the result page whether captcha is entered correctly or not.</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:420px;max-width:420px;height:120px;text-align:left;overflow:auto"><code>
<pre>
&lt;%@page contentType="text/html" pageEncoding="UTF-8" %&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8?&gt;
&lt;title&gt;Captcha&gt;/title&gt;
&lt;link rel="stylesheet" href="theme/style.css"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
&lt;%=request.getAttribute("result")%&gt;
&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p></code></pre>
</div>
<p>
Don&#8217;t forget the folder format projectfolder->jsp files,web-inf<br />
In web-inf->web.xml,classes folder->in classes folder servlet classes<br />
Finally run the project by visiting the url http://localhost:8080/captcha/,any doubt comment us happy coding.</p>
<p><a href="http://s2sgateway.com/jsp/captcha-project-in-jspservlet/">captcha project in jsp/servlet</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/jsp/captcha-project-in-jspservlet/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>pagination in jsp,java</title>
		<link>http://s2sgateway.com/my-sql/pagination-in-jspjava/</link>
		<comments>http://s2sgateway.com/my-sql/pagination-in-jspjava/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 11:02:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[J2EE codes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[my sql]]></category>
		<category><![CDATA[projects download]]></category>
		<category><![CDATA[how to create pagination in jsp]]></category>
		<category><![CDATA[how to limit no of values to be retreived from database]]></category>
		<category><![CDATA[how to remove duplicate values from database]]></category>
		<category><![CDATA[LIMIT in mysql]]></category>
		<category><![CDATA[mysql connection error]]></category>
		<category><![CDATA[need a bank project in vb click here]]></category>
		<category><![CDATA[pagination in jsp]]></category>
		<category><![CDATA[paging in jsp]]></category>
		<category><![CDATA[retrieving values in jsp]]></category>
		<category><![CDATA[retrieving values in mysql]]></category>
		<category><![CDATA[simple pagiantion with struts]]></category>
		<category><![CDATA[simple pagination in java]]></category>
		<category><![CDATA[simple pagination in jsp with hibernate]]></category>
		<category><![CDATA[too]]></category>
		<category><![CDATA[too many connection]]></category>
		<category><![CDATA[too many connection error]]></category>
		<category><![CDATA[too many connection in tomcat]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=405</guid>
		<description><![CDATA[pagination in jsp,java is a post from: s2sgateway<p><a href="http://s2sgateway.com/my-sql/pagination-in-jspjava/">pagination in jsp,java</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[pagination in jsp,java is a post from: s2sgateway<p><a href="http://s2sgateway.com/my-sql/pagination-in-jspjava/">pagination in jsp,java</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/my-sql/pagination-in-jspjava/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Finding created/modified time of files in a folder</title>
		<link>http://s2sgateway.com/common/finding-createdmodified-time-of-files-in-a-folder/</link>
		<comments>http://s2sgateway.com/common/finding-createdmodified-time-of-files-in-a-folder/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 16:02:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Common]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[created time of a file]]></category>
		<category><![CDATA[Finding created time of files in a folder]]></category>
		<category><![CDATA[finding difference between dates]]></category>
		<category><![CDATA[finding modified time of a file in jsp]]></category>
		<category><![CDATA[finding modified time of folder in jsp]]></category>
		<category><![CDATA[finding time of a folder]]></category>
		<category><![CDATA[time in jsp]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=382</guid>
		<description><![CDATA[Today we are going to learn about how to retrieve the created time and date of all files in a folder. This is useful when you want to track the session information of certain files or folders.Lets look the code below. &#60;%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.io.File, java.util.Date, java.util.Calendar" errorPage="" %&#62; &#60;html&#62; &#60;head&#62; &#60;title&#62;Untitled Document&#60;/title&#62; [...]<p><a href="http://s2sgateway.com/common/finding-createdmodified-time-of-files-in-a-folder/">Finding created/modified time of files in a folder</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Today we are going to learn about how to retrieve the created time and date of all files in a folder.<br />
This is useful when you want to track the session information of certain files or folders.Lets look the code below.</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:520px;max-width:520px;height:220px;text-align:left;overflow:auto"><code>
<pre>
&lt;%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.io.File, java.util.Date, java.util.Calendar" errorPage="" %&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;/head&gt;

&lt;%
  String dir_name = "C:\\foldername";
  //String dir_name = "/";  This line will give u the windows drive's root folder.

  File fold = new File(dir_name);    

  if(fold.exists())
  {
      String all_files[] = fold.list();
     int no_of_files = all_files.length;

     for(int i=0; i&lt;no_of_files; i++)
      {
        File f = new File(dir_name + "\\" + all_files[i] );
        String complete_file_name = f.getPath();
        String file_name = f.getName();
        long last_modified_ms = f.lastModified();
        Date date = new Date(last_modified_ms);
        Calendar cal_date = Calendar.getInstance();
        cal_date.setTime(date);
        String last_modified_date = cal_date.get(Calendar.MONTH) + "-" + cal_date.get(Calendar.DATE) +"-"+ cal_date.get(Calendar.YEAR);
        String last_modified_time = cal_date.get(Calendar.HOUR) + ":" + cal_date.get(Calendar.MINUTE) +":"+ cal_date.get(Calendar.SECOND);
%&gt;       

        &lt;a href="&lt;%=complete_file_name%&gt;"&gt;  &lt;%=file_name%&gt;  &lt;/a&gt;   &lt;b&gt;Last Modified by &lt;/b&gt; &lt;%=last_modified_date%&gt;      &lt;b&gt;at &lt;/b&gt; &lt;%=last_modified_time%&gt;
        &lt;br&gt;   

&lt;%

      }//end of for

  }//end of if
  else
     out.println("Folder does't exist");
%&gt;
  &lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p></code></pre>
</div>
<p>Try this example and do comment us Happy coding.</p>
<p><a href="http://s2sgateway.com/common/finding-createdmodified-time-of-files-in-a-folder/">Finding created/modified time of files in a folder</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/common/finding-createdmodified-time-of-files-in-a-folder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating captcha(random letter image) in jsp</title>
		<link>http://s2sgateway.com/jsp/creating-captcharandom-letter-image-in-jsp/</link>
		<comments>http://s2sgateway.com/jsp/creating-captcharandom-letter-image-in-jsp/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:07:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[captcha creation]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Jsp]]></category>
		<category><![CDATA[Servlet]]></category>
		<category><![CDATA[automatic captcha creation]]></category>
		<category><![CDATA[captcha creation using servlet]]></category>
		<category><![CDATA[captcha creator free download]]></category>
		<category><![CDATA[captcha image using servlet]]></category>
		<category><![CDATA[captcha in jsp form]]></category>
		<category><![CDATA[captcha using servlet]]></category>
		<category><![CDATA[create captcha easily]]></category>
		<category><![CDATA[how to create a captcha in java]]></category>
		<category><![CDATA[how to create a captcha in jsp]]></category>
		<category><![CDATA[random letters in servlet]]></category>
		<category><![CDATA[stop spam using captcha]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=378</guid>
		<description><![CDATA[Today we are going to learn how to create a random letter image known as captcha using servlet. Just a simple coding can do it copy the code below and save it and compile it you can directly view the servlet in tomcat using url &#8220;http://localhost:8080/captcha/servlet/CaptchaServlet&#8221; for this make adjustment in web.xml file by adding [...]<p><a href="http://s2sgateway.com/jsp/creating-captcharandom-letter-image-in-jsp/">Creating captcha(random letter image) in jsp</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Today we are going to learn how to create a random letter image known as captcha using servlet.<br />
Just a simple coding can do it copy the code below and save it and compile it you can directly view the servlet in tomcat using url &#8220;http://localhost:8080/captcha/servlet/CaptchaServlet&#8221; for this make adjustment in web.xml file by adding servlet and servletmapping entries.</p>
<div style="margin-bottom:2px">
<pre style="margin:0px;padding:6px;border:1px inset;width:490px;max-width:490px;height:220px;text-align:left;overflow:auto"><code>
<pre>
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CaptchaServlet extends HttpServlet {

private static final long serialVersionUID = 1L;

protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

final int width = 200;
final int height = 50;

char data[][] = new char[1][];
data[0] = getRandomNumber(8).toCharArray();

final BufferedImage bufferedImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);

final Graphics2D g2d = bufferedImage.createGraphics();

final Font font = new Font("verdana", Font.BOLD, 18);

RenderingHints renderingHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

renderingHints.put(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);

g2d.setRenderingHints(renderingHints);

g2d.setFont(font);
g2d.setColor(new Color(255, 255, 0));
final GradientPaint gradientPaint = new GradientPaint(0, 0, Color.white, 0, height / 2,
Color.white, true);

g2d.setPaint(gradientPaint);
g2d.fillRect(0, 0, width, height);

g2d.setColor(new Color(255, 155, 0));
Random random = new Random();

final String captcha = String.copyValueOf(data[0]);
request.getSession().setAttribute("captcha", captcha);

int xCordinate = 0;
int yCordinate = 0;

for (int i = 0; i < data[0].length; i++) {
xCordinate += 10 + (Math.abs(random.nextInt()) % 15);
if (xCordinate >= width - 5) {
xCordinate = 0;
}
yCordinate = 20 + Math.abs(random.nextInt()) % 20;
g2d.drawChars(data[0], i, 1, xCordinate, yCordinate);
}

g2d.dispose();

response.setContentType("image/png");
final OutputStream outputStream = response.getOutputStream();
ImageIO.write(bufferedImage, "png", outputStream);
outputStream.close();
}

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}

public static String getRandomNumber(int length) {

String chars = "www.s2sgateway.comabcdefghjijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789";
Random random = new Random();

char[] buf = new char[length];

for (int i = 0; i < length; i++) {
buf[i] = chars.charAt(random.nextInt(chars.length()));
}

return new String(buf);

}

}
</pre>
<p></code></pre>
</div>
<p>
that's it you have created captcha image using servlet,Here you can give any letters or numbers in String chars = "";assignment values.<br />
Change the color by changing this code "final GradientPaint gradientPaint = new GradientPaint(0, 0, Color.white, 0, height / 2,<br />
Color.white, true);"Here i used this image as png because it is good for web developement, you can try others as well like jpg or gif do comment us<br />any doubt ask us Happy coding.</p>
<p><a href="http://s2sgateway.com/jsp/creating-captcharandom-letter-image-in-jsp/">Creating captcha(random letter image) in jsp</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/jsp/creating-captcharandom-letter-image-in-jsp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reading Html code of all the url using java</title>
		<link>http://s2sgateway.com/java/reading-html-code-of-all-the-url-using-java/</link>
		<comments>http://s2sgateway.com/java/reading-html-code-of-all-the-url-using-java/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 14:01:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[buffered reader in java]]></category>
		<category><![CDATA[ieee project in java]]></category>
		<category><![CDATA[import java.net.* use in java]]></category>
		<category><![CDATA[input stream reader in java]]></category>
		<category><![CDATA[network application in java]]></category>
		<category><![CDATA[read url in java]]></category>
		<category><![CDATA[simple java network program]]></category>
		<category><![CDATA[url reader in java]]></category>

		<guid isPermaLink="false">http://s2sgateway.com/?p=365</guid>
		<description><![CDATA[A simple tricky program that can read all the html codes of given url using java the following code does that import java.net.*; import java.io.*; public class URLReader { public static void main(String[] args) throws Exception { URL yahoo = new URL("http://www.yahoo.com"); BufferedReader in = new BufferedReader( new InputStreamReader( yahoo.openStream())); String inputLine; while ((inputLine = [...]<p><a href="http://s2sgateway.com/java/reading-html-code-of-all-the-url-using-java/">Reading Html code of all the url using java</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></description>
			<content:encoded><![CDATA[<p>A simple tricky program that can read all the html codes of given url using java the following code does that</p>
<pre>
import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {
	URL yahoo = new URL("http://www.yahoo.com");
	BufferedReader in = new BufferedReader(
				new InputStreamReader(
				yahoo.openStream()));

	String inputLine;

	while ((inputLine = in.readLine()) != null)
	    System.out.println(inputLine);

	in.close();
    }
}
</pre>
<p>Compile and run this java file give any url you want to read in here URL yahoo = new URL(&#8220;http://www.yahoo.com&#8221;);<br />
Any doubt Ask us Happy coding</p>
<p><a href="http://s2sgateway.com/java/reading-html-code-of-all-the-url-using-java/">Reading Html code of all the url using java</a> is a post from: <a href="http://s2sgateway.com">s2sgateway</a></p>
]]></content:encoded>
			<wfw:commentRss>http://s2sgateway.com/java/reading-html-code-of-all-the-url-using-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>


