Thursday, April 14, 2016

My Datamining Research for tourism:

When ever we travel we make sure that there must be an adventurious trip ahead,but when that tour get lots of hurdles then we may be unsatisfied or may be frustrated instead of refreshment, so to avoid that every travel agencies make use of ratings. If we consider ratings of unknown then there may be fraud or fake ratings, so thats the thing we make use of only tour users who choose packages and have travelled through that agency.
     
     For that reason I have developed two models. one is SATT (Season Area Tourist Topic) where tourist will give two topics area and season, according to that selection deserved packages will be shown so taht you can take decision easily where to travel, and the second model is SARTT (Season Area Relational Tourist Topic) Now after getting booked with package travel agency will look after the mass group where if they take all at once, then there may be arguements among themeselves, so to avoid that we have developed this Model so that according to age groups tourist will be arranged and will be taken to spots.

So below is the Topic name and link of my research....

A Decision Making System for Tourist Using Collaborative Approach


for more updates and research, follow this blogspot.     

Thursday, April 7, 2016

Get Number of Website Visitors and Their Details:

Index.jsp:

<%@page import="java.sql.*"%>
<%@page import="java.io.*, java.util.Date"%>

<!DOCTYPE html>
<html lang="hi">
<head>  
    <title>Grab Visitor detail</title>
   <meta charset="utf-8"> //below are the bootstrap included path.
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
 
  <link rel="stylesheet" href="css/ezomart.css" type="text/css">
 <link rel="icon" type="image/png" href="images/favicon.png" sizes="160x160">

// jsp code to get Ip of user and current date and time when user opens this page.

<%
    Integer hitsCount = (Integer) application.getAttribute("hitCounter"); 
    if( hitsCount ==null || hitsCount == 0 ){    
       /* First visit */    // setting counter (1...n) it will increase when ever a new visit to page happens
             hitsCount = 1;
    }else{
       /* return visit */
              hitsCount += 1;
    }
// setting count attribute and getting IP, HOST of user.
    application.setAttribute("hitCounter", hitsCount);
   String ipAddress = request.getRemoteAddr();
   String host=request.getRemoteHost();
  application.setAttribute("IP", ipAddress);
  application.setAttribute("host", host);

  Date d=new Date();  // Getting date
  String datee=d.toString();  // converting date to string
    Connection con=null;
Statement st=null;
ResultSet rs=null;   
 // start opening DB and insert count IP and date into DB for saving visitor record.  
         try{                           
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");   
         con=DriverManager.getConnection("jdbc:odbc:DB_NAME");
   st=con.createStatement();
 // storing visitor record to DB
 String sql="insert into visits values ('"+hitsCount+"','"+ipAddress+"','"+datee+"')";         
    
    int x=st.executeUpdate(sql);
   if(x!=0)
    {
                 
   }
                       else{
 response.sendRedirect("load_error.jsp"); // below is load_error.jsp
                       }

             con.close();
        st.close();}
         catch(SQLException e)
                                 { 
         response.sendRedirect("load_error.jsp");
         }
    %>

</head>
<body>

Akshay Morkhandikar Welcome's you.
have nice day.

</body>
</html>

load_error.jsp:


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Error 500</h1>
        <p>please try again <a href="index.jsp">Home</a></p>
    </body>
</html>

Saturday, April 2, 2016

SQLException: General Error



If you get any error for sql using ms-access or oracle

then do check with

con.commit();
con.close();
st.close();  

if still problem persists then plz have look at this link  --> Java database operations     

you will have a great information over there...


thank you,
have a nice day..... :)   

Monday, March 28, 2016

Login Validation for paid and unpaid users with eradication of SQL Injection:

HTML Page:

<html>
<body>
<form action="login.jsp" method="post">
<label>User:</label>
<input type="email" name="uname" required><br>
<label>Password:</label>
<input type="password" name="pass" required><br>

<button type="submit">Login</button>
</form>
</body>
</html>

JSP for Login:


<%@ page import="java.sql.*"%>
<% 
         String name=request.getParameter("uname"); //getting uname from html page
String pass=request.getParameter("pass");    // getting password from html
if(name==null && pass==null && name=="" && pass=="")
{
out.println("please fill all fields");
}
Connection con=null;
Statement st=null;
ResultSet rs=null;
String sql= " select * from users where users= ' "+name+" ' ";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");           // the driver may differ as this is for ms access.
  con=DriverManager.getconnection("jdbc:odbc:DB_Name");
   st=con.createStatement();
   rs=st.executeQuery(sql);
   if(rs.next())
    {
                String user=rs.getString(1);   //getting username from DB
                String passwrd=rs.getString(2);   //getting password from DB
                
                if (pass.matches(passwrd))       // using matches method for password so that SQL Injection fails.
                                   {
                    session.setAttribute("userid", user);          //setting userid and password as session for filteration.
                     String verify=rs.getString(9);
                    if(verify.matches("paid"))              // verifying user if paid or not.
                 {
%>
<jsp:forward page="paiduser.jsp"/> // if user is paid it will go to paid user page else to unpaid  user page.
    <%
                                 }
                               else
                               {
                                                   %>
        <jsp:forward page="unpaiduser.jsp"/>
            <%
                               }
  
               } 
 out.println("Oop's! you are not Authenticated Person");
               
            
        } }
catch(SQLException e1)
{
System.out.println(e1);
}

finally
{
    st.close();
     con.close();
}
            %>

Tuesday, March 22, 2016

Tool for Json file Conversion.
Get the Data from DB And Make a json file for parsing it in Android or in any applications.

<%@ page import="java.io.*,java.util.*, javax.servlet.*, java.sql.*" %>
<%
Connection con=null;
    Statement st=null;
    ResultSet rs=null;
    String cid=" ";
    String cname=" ";
            String category=" ";
            String image=" ";
            String num=" ";
            String area=" ";
            String video=" ";
            String user=" ";
          String sql="select * from company";   //query passed in rs=st.executeQuery(sql);
    
      //File creation
 String strPath = "F:\\company.json";     // file path to store file at with this extension .json name
 File strFile = new File(strPath);
 boolean fileCreated = strFile.createNewFile();         // file creation with name and with (.)dot extension json
 //File appending
 Writer objWriter = new BufferedWriter(new FileWriter(strFile));
objWriter.write("{'employees':[");     //json object creation with name employee.
try                 //getting connection and values from DB. (attributes like address will have problem in json as we will have substring in that, so use xml for that)
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");     
con=DriverManager.getConnection("jdbc:odbc:DB_name");
   st=con.createStatement();
   rs=st.executeQuery(sql);
   while(rs.next())      //while will iterate and print all values in this object
                     {
                cid=rs.getString(1);
                cname=rs.getString(2);
                category =rs.getString(3);
                image =rs.getString(6);
                num=rs.getString(9);
                area=rs.getString(10);
                video=rs.getString(11);
                user=rs.getString(14);
             
 objWriter.write("{'cid':'"+cid+"', 'company Name':'"+cname+"', 'category':'"+category+"', 'image':'http://www.xyz.com/"+image+"', 'number':'"+num+"', 'area':'"+area+"', 'video':'http://www.xyz.com/"+video+"', 'User':'"+user+"'},");  // finish it in one line.
     
            }
            objWriter.write("]}"); // after iteration close the while and close the employees object
            objWriter.flush();   
 objWriter.close();            
 out.println("JSON Generated successfully");     //JSON file generated.
             
}
catch(SQLException e)            
               {
    out.println(e);
}
%> 


Net beans Build Failed When 

" Deployment error: Access to Tomcat server has not been authorized. Set the correct username and password with the "manager-script" role in the Tomcat customizer in the Server Manager. See the server log for details. "


This happens when you change your username and password in your netbeans, as your netbeans tomcat will have tomcat-user.xml which have default value, either change that or else maintain that record..

to check and rectify mistake go to:

C:\Documents and Settings\{User}\.netbeans\7.1\apache-tomcat-7.0.22.0_base\conf

you can find tomcat-user.xml
open that with notepad and see the last line
it must be

<user username="ide" password="Agt7ViLa" roles="manager-script,admin"/></tomcat-users>

again go back to netbeans
  • click on tools
  • select servers.
  • set Username: "ide" & password: "Agt7ViLa".

or else change it. but you have to edit the file as well as in netbeans.
then go to netbeans and run the project.

For more info subscribe us or follow us at aksoftdeveloper.blogspot.in or contact us at softdevelopr007@gmail.com

Bye Have a nice day

Monday, March 21, 2016

New User Signup: create folder when signup and a row in a DB:

//HTML Page for Signup form


<%-- 
    Document   : signup
    Created on : Feb 11, 2016, 11:33:09 AM
    Author     : Ak-47
--%>
<!DOCTYPE html>
<html>
    <head>
        <title>signup</title>
  <meta charset="utf-8">
    <script>
    function myFunction()  // function to check passsword and confirm password
    {
    var a,b;
    a=document.form1.pass.value;
    b=document.form1.passw.value;
    
    if(a!=b || a=="")
        {
         alert("Password doesnt match");  
         form1.action = 'http://www.google.com/';
         
        }
        else
            {
             form1.action='insertuser.jsp';   
            }
    }
</script>
    </head>
    <body>
       
            <form name="form1" onsubmit="myFunction()" action="insertuser.jsp" method="post">
  
    <label>First Name: </label>
           <input type="text" name="fname" placeholder="Enter First Name" required>
   
    <label>Last Name: </label>
         <input type="text" name="lname" placeholder="Enter Last Name" required>
   
    <label>Email:</label>
      <input type="email" name="email" placeholder="Enter email" required>
 
 <label>Mobile:</label>
      <input type="text" name="mobile" placeholder="Enter Cellular Number" required>
   
            <label>Password:</label>
      <input type="password" name="pass" placeholder="Enter password" required>
            
    <label>Confirm Password:</label>
      <input type="password" name="passw" placeholder="Enter password again" required>
   
         <label>Date of Birth:</label>
      <input type="date" name="dob">
            
   <label>Gender:</label>
        <select name="gender">
          <option value="Male">Male</option>
    <option value="Female">Female</option>
    <option value="Transgender">Transgender</option>
      </select>
      
                  <label>Address:</label>
        <textarea rows="5" name="address" required></textarea>
    
      <button type="submit" class="btn btn-default">Submit</button>
    </form>
    
    </body>
</html>

//JSp page (Insertuser.jsp)

<%-- 
    Document   : insertuser
    Created on : Feb 11, 2016, 1:53:30 PM
    Author     : Ak-47
--%>
<%@ page import="java.io.*,java.util.*, javax.servlet.*, java.sql.*, databasecon.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
        <%

//declaring all the variables

        String fname=request.getParameter("fname");
        String lname=request.getParameter("lname");
        String userid=request.getParameter("email");
        String pass=request.getParameter("pass");
        String mobile=request.getParameter("mobile");
        String dob=request.getParameter("dob");
        String gender=request.getParameter("gender");
        String address=request.getParameter("address");
            
        String filePath="C:/proj/zot/web/user"; 
// declaring the file path where we want to create user folder and upload data later.
        
       try
       { 
File root = new File(filePath);
        File newfolder = new File(root, "/"+userid); //creating the new folder
            newfolder.mkdir();
                    filePath=filePath+"/"+userid+"/";
                    File newfldr = new File(filePath, "gallery");
            newfldr.mkdir();
            File newfoldr = new File(filePath, "products");
            newfoldr.mkdir();   

                Connection con=null;
Statement st=null;
      String sql="insert into users values ('"+userid+"','"+pass+"','"+fname+"','"+lname+"','"+dob+"','"+gender+"','"+mobile+"','"+address+"')";         
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getconnection("jdbc:odbc:DB_Name");  //these drivers are only for ms-access.
  st=con.createStatement();
   int x=st.executeUpdate(sql);
   if(x!=0)
    {
out.println("created successfully : <h2>"+userid+" : "+mobile+"</h2><br>");
             out.println("for more details Contact us. <br>");
   }
                       else
                       {
 out.println( userid + " already exists");
                   
                       }
            st.close();
            con.close();
        
                                           
       }
       catch(SQLException e)
                             {
      out.println(userid +" Already exists "+e);
       }
    %>
    </body>
</html>

Contact Us At: softdevelopr007@gmail.com