s2sgateway

Practical Learning of Programming languages such us j2ee,java,jsp

Enter your email address to subscribe tutorials and projects:

  Powered by FeedBurner

PTC is Time Killer,how to find true PTC-part2

As I already touched up certain concept about PTC.In PTC sites are scams?& how to find tru ptc part-1.This is the continuation of the theory.
These days there are many online oppurtunities articles,how to articles are spread around the internet like “how to make money online”,”make money in 10 minutes”,”online money making oppurtunities”,”Surf and make money”,”paid to surf”,”paid to read” like that lot of those are scams but look like genuine in the way of writing,Most of us read those articles and register in those websites and spend our valuable time to read the instructions and click the ads provided by them,what we get from those sites is 1$ for clicking 1000 times but it is not premanent any time your account is suspended and the site is closed,So if we spend those time in learning some programming and creating a software will make you rich and it is worthy for life time.
Try to Avoid these temporary time consuming works online instead work as a freelancer and enjoy the internet with money making techniques.
If you really want to do PTC then after entering there site check for Verification by any ssl provider those who are verified only pay to you.Happy surfing

how to find your site PR,incoming links

There are many possible ways to find your sites google Page rank,alexa rank but i found a site which provides all the information quickly and efficiently in single click Visit here
You know about your incoming links,google page rank,alexa page rank,dmoz listing etc.Happy SEO

Which is best .net or j2ee

Today there are many students are eager to learn programming but they don’t know which platform to select.
There are many languages other than .net and j2ee but these two are having wide range of popularity.
Today i am going to give some idea for you to select your platform well and do best programming with creativity
If you are a person has some strong knowledge in c,c++ and some basic knowledge in java then it’s always a good idea to choose j2ee as a platform without basic knowledge in java it is difficult to learn struts,hibernate,spring,jsf and etc.
If you are a person have some knowledge in c,VB then choose .Net as your choice.

.Net vs J2ee
Both are used for web development if you are lazy programmer wants the things straight and easy choose .Net,If you want to be more competitive then good choice is j2ee
The Language .Net runs in Microsoft platform only as for as j2ee you can have run in different platforms,variety of IDE’s to use like NetBeans,Eclipse,BEA Welogic etc and because of opensource you can get everthing updated and freely.

My Vote goes to open source community J2ee what is yours,Happy coding

Solving the c:\fakepath problem/upload problem easily

There is a situation when you want to get the string that is returned by the value attribute of a file upload input <input type=”file” name=”upload”/> under Internet Explorer 8?But the desired full path is not passing in the parameters only name of the file is passing,When you put a simple javascript ie onclick the browse button and get the value in javascript document.form.upload.value and alert the value then you get alert value as “c:\fakepath”
Actually This is because of changes in W3C the real path to the file will be shown only if the page that contains the control is added to the trusted sites collection of the browser

solution for internet explorer

Go to tools ->internet options->security->trusted sites->sites->Enter
http://localhost ->click add and
uncheck require https

solution for firefox>h4>
Go to tools->options->security->Exceptions->add the site http://localhost as trusted site
Now you get the exact values in the upload attribute.?Happy coding

Paypal Resuming local bank withdrawals to India

There are many complaints from indian customers that their withdrawl money from paypal is delayed in feb.
Finally paypal announced its problem with RBI due to new policy for withdrawl to safe guard from false and unauthorized transaction.
But now they have solved the problem and resume there services to indian bank from march3.


we are happy to announce that the RBI has allowed us
to continue local bank withdrawals for settlements for exports
of goods and services. We are currently making changes to
comply with Indian regulations for settlements for exports of
goods and services, and we anticipate that, as of Wednesday,
March 3rd, customers will be able to use our bank withdrawal service.
As part of the changes, you will be required to fill out a
new field entitled 'Export Code' when you request a withdrawal.
This information is required under the current laws of India in
order to identify the nature of cross-border merchant transactions.
On Monday, March 1st, we will be back in touch with specific
instructions on how you can move your money into your bank account.
Moving forward, the RBI has told us that PayPal needs specific
approvals to allow personal remittances to India, which we
currently do not have. Until we get these approvals, personal
payments into India will remain suspended. However, if you are
an exporter, you will continue to be able to use the PayPal
service for payments of goods and services

For more info see www.thepaypalblog.com
for details,Dont worry Hope no one’s money will lost.

how to download files from rapidshare as a premium member

Now you can download unlimited files from rapidshare,megaupload,hotfile etc without waiting.
It was a big annoyment when you want to download a file but there is another user already downloading from your shared ip,so you have to wait until his downloading is finished.
To overcome this i have found a site which uses the different methodology so that you can download the files with the direct link
All you have to do is visit this site
Copy your download link and you will get a direct link to download immediately without wait.
Happy downloading.

compare current time with database retrieved time in jsp

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 time.


<%@ page language="java" import="java.util.*,java.sql.*,java.math.*,java.text.SimpleDateFormat"pageEncoding="ISO-8859-1"%>
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);
%>



Have a doubt leave a comment,Happy coding

captcha project in jsp/servlet

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 captcha and another for checking the captcha and a result page for showing the result.

.



First create a simple form like below


<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset=UTF-8?>
<title>Captcha Project from www.s2sgateway.com>/title>
</head>
<body>
<center>
<form method="post" action="checkCaptcha.do">
<table cellspacing="15?>
<tr>
<td align="center">
<img src="CaptchaServlet.do">
<br />
<br />
<input type="text" name="code">
</td>
</tr>
</table>
<input type="submit" value="submit">
</form>
<br>
<br>>/center>
</body>
</html>

create web.xml file for necessary servlet entry


<web-app>
<servlet>
<servlet-name>CaptchaServlet>/servlet-name>
<servlet-class>
CaptchaServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>CheckCaptcha>/servlet-name>
<servlet-class>
CheckCaptcha
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CaptchaServlet>/servlet-name>
<url-pattern>/CaptchaServlet.do>/url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CheckCaptcha>/servlet-name>
<url-pattern>/checkCaptcha.do>/url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp>/welcome-file>
</welcome-file-list>
</web-app>

now create the servlet which produces random image>br>


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);
}
}

Now for checking the image servlet you can write the servlet code as follows>br>



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 && 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);
}
}
}

Finally write the code in the result page whether captcha is entered correctly or not.


<%@page contentType="text/html" pageEncoding="UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8?>
<title>Captcha>/title>
<link rel="stylesheet" href="theme/style.css">
</head>
<body>
<center>
<%=request.getAttribute("result")%>
</center>
</body>
</html>

Don’t forget the folder format projectfolder->jsp files,web-inf
In web-inf->web.xml,classes folder->in classes folder servlet classes
Finally run the project by visiting the url http://localhost:8080/captcha/,any doubt comment us happy coding.

pagination in jsp,java

Hai all today we are going to learn how to create a pagination in jsp.
Understanding Pagination is first of all important,Retrieving and showing 50 values in a page is not a problem if it is more than 100 or 200 values then page which is showing is too long and time to load so know now,Actually pagination is when you want to retrieve all values from database but show only limited value in first page and if users wants he clicks on second page to view the remaining items.
Lets create the table
“create table chart(name varchar(20));”
I use mysql if you use anyother db change the coding connection lines according to that.

Here is the jsp code


<%@page import="java.sql.*,java.io.*,java.math.*,java.lang.*"%>
Tutorial from www.s2sgateway.com give your comments
<h1>Simple pagination in jsp from www.s2sgateway.com</h1>
<%
int total_entries=0;
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/s2sgateway","root","root");
Statement st=con.createStatement();
Statement st1=con.createStatement();
ResultSet rs=st.executeQuery("SELECT count(*)  from chart");
rs.next();
int count=rs.getInt(1);
 total_entries =count;

int page_number=0;

int total_pages=0;
int i;
int entries_per_page = 2;
if(request.getParameter("page_number")!=null)
{
page_number = Integer.parseInt(request.getParameter("page_number"));
} else {
page_number = 1;
}
total_pages = (total_entries / entries_per_page);
int offset = (page_number - 1) * entries_per_page;
ResultSet rs1=st1.executeQuery("SELECT * FROM chart ORDER BY name ASC LIMIT
"+offset+","+entries_per_page);
while(rs1.next())
{
out.println(rs1.getString(1));
// Display the data anything from database

}
for(i = 1; i <= total_pages; i++)
{ if(i == page_number)
 {
 // This is the only page. so no link
out.println("pagenumber"+i);
 }
 else {
 // This is not the only page. Make it a link.

%>
<a href="pagination.jsp?page_number=<%=i%>"><%=i%></a>
<%
 }
 }
%>

Here entries_per_page is the no of entries you need on the page.It display links when database values more than 3.Otherwise display values in one page.You can modify this code to suite with hibernate and struts as well.Any doubt ask us happy coding

PTC sites are scams?& how to find tru ptc part-1

Hai friends basically this website is for programming all of a sudden when i was searching in internet,i found a word PTC(ie point to click)in many websites and forums then i took a research on them what it actually mean
1.whether they are legitimate?
2.whether it pays?
finally i found some results that i want to share with you guys.
First understand the concept
what you want to do is actually click the links that is ads given by advertisers to them.For each click some points is given and finally you can exchange it with dollars looks simple but see the truth behind it

1click=0.0001$ actually you need to click atleast 800 times to change this to 0.1000$ what is actually mean is 10cent you need to get 100 cent to make 1$ ie 8000 clicks do you think working for this much time and make this 1$ is legitimate or scam.
Ok you achieved 1$ but how many of them know whether actually they are paying.
So be careful from some of irresponsible sites and i give you legitimate sites that really pays
Don’t waste your time click below link to see scam sites

Scam sites list
No-minimum
donkeymails
incentiveclix
1dollarptc
list will grow when i found others sure comment your list of scam sites

Legitimate sites that really Pays

1.Surveys online
2.Legitimate Site

Disclaimer:
This information here presented is for informative purpose only,and information are taken from internet only,so any of you find the above sites are legitimate contact us we will analyze and remove your site from the post.Thank you