Saturday, 27 April 2013

CSS for sample HTML form


@charset "utf-8";
/* CSS Document */

body{
margin:0;
color:#232323;
padding-top: 0px;
padding-right: 0;
padding-bottom: 100px;
padding-left: 0;
background:#FFFFFF;
background-attachment:scroll;
}
table
  {
  margin-left: auto;
  margin-right: auto;
  backgroung:
  }
div, h1, h2, h3, h4, p, form, label, input, textarea, img, span
{
margin:0; padding:0;
}

ul
{
margin:0;
padding:0;
list-style-type:none;
font-size:0;
line-height:0;
}


.spacer{
clear:both;
font-size:0;
line-height:0;
}
img
{
border:none;
}

/*---------------------table----------------------------*/
table.altrowstable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #a9c6c9;
border-collapse: collapse;
}
table.altrowstable th {
border-width: 1px;
padding: 14px;
border-style: solid;
border-color: #a9c6c9;
}
table.altrowstable td {
border-width: 1px;
padding: 14px;
border-style: solid;
border-color: #a9c6c9;
}
.oddrowcolor{
background-color:#d4e3e5;
}
.evenrowcolor{
background-color:#c3dde0;
}
/*------------------------------------------------body--------------------*/

#header
{
margin:0 auto;
padding:0px;
width:929px;
height:250px;
background:url(images/header.jpg) center no-repeat;
}
#image
{
width:500px;
height:100px;
background:url(C:/Users/Gargi/Pictures/home.png) center no-repeat;
}
#body
{
color:#232323;
margin:0 auto;
padding:0px;
width:929px;
height:800px;
background:#4299da;
}
#navigation
{
width:929px;
height:36px;
margin:0 auto;
padding-top:8px;
background:url(images/navigation_bg.jpg) 0 0 repeat-x;
}
#navigation ul
{
list-style:none;
}
#navigation ul li
{
font:bold 12px/28px Arial, Helvetica, sans-serif;
color:#ffffff;
display:block;
float:left;
background:url(images/li_bg.jpg) right center no-repeat;
text-align:center;
padding:0px 5px;
}
#navigation ul li a
{
text-decoration:none;
display:block;
color:#FFFFFF;
}
#navigation ul li a:hover
{
text-decoration:underline;
display:block;
color:#FFFFFF;
background:url(images/navigation_hover.jpg) bottom center no-repeat;
}

#content
{
margin:0 auto;
width:929px;
padding:5px 0;
}
h1
{
font:bold 24px/28px Arial, Helvetica, sans-serif;
color:#676767;
}
h2
{
font:bold 18px/24px Arial, Helvetica, sans-serif;
color:#e67621;
}
h3
{
font:normal 12px/20px Arial, Helvetica, sans-serif;
color:#a9a9a9;
}
h4
{
font:bold 20px/28px Arial, Helvetica, sans-serif;
color:#676767;
padding-left:25px;
}
p
{
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#414141;
}
.orange
{
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#cf570c;
}
.black
{
font:bold 12px/18px Arial, Helvetica, sans-serif;
color:#000000;
}
#content_top
{
margin:0 auto;
width:929px;
padding:5px 0;
}
#find
{
margin:0;
background:#eeeeee;
width:280px;
padding:6px;
}
#find form input.textbox
{
width:146px;
}
#select
{
width:150px;
}
#find form input.find
{
width:106px;
height:25px;
background:url(images/find.jpg) 0 0 no-repeat;
border:none;
}
#main_content
{
float:right;
width:612px;
}
#house_sales
{
margin:5px auto;
width:600px;
}
.house_sales
{
font:bold 12px/31px Arial, Helvetica, sans-serif;
color:#000000;
width:184px;
height:31px;
background:url(images/price_bg.jpg) center no-repeat;
text-align:center;
margin:5px auto;
}
#content_bottom
{
margin:0 auto;
width:929px;
padding:10px 0;
}
.features
{
float:left;
width:285px;
padding:6px;
}
.features_content
{
margin:5px auto;
width:195px;
text-align:justify;
padding-left:70px;
}
.more
{
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#4299da;
}
.more a
{
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#4299da;
}
.more a:hover
{
font:normal 12px/18px Arial, Helvetica, sans-serif;
color:#4299da;
}
#Details
{
font:bold;
margin:0 auto;
padding:0px;
width:929px;
height:300px;
color:#676767;
}
#Details a:hover
{
text-decoration:underline;
display:block;
/*color:#FFFFFF;*/
background:url(images/navigation_hover.jpg) bottom center no-repeat;
}

/*Example for a Menu Style*/
.menu
{
width:919px;
height:36px;
margin:0 auto;
padding-top:8px;
background:url(images/navigation_bg.jpg) 0 0 repeat-x;
}
.menu ul
{
margin:0px;
padding:0px;
list-style:none;
text-align:center;
}
.menu li
{
font:bold 12px/28px Arial, Helvetica, sans-serif;
    color:#ffffff;
    display:block;
    float:left;
    background:url(images/li_bg.jpg) right center no-repeat;
    text-align:center;
    padding:0px 5px;
}
.menu li a
{
color:#ffffff;
text-decoration:none;
padding:4px 5px 6px 5px;
border-left:1px solid #ececec;
border-right:1px solid #ececec;
}
.menu li a.tabactive
{
border-left:1px solid #d7d7d7;
border-right:1px solid #d7d7d7;
background-color:#CCCCCC;
font-weight:bold;
position:relative;
}
/*------------------------------------------------fotter--------------------*/
 #fotter
{
margin:0 auto;
padding:13px 5px;
height:24px;
background:#2f2f2f;
width:919px;

}
.design_info
{
margin:0 auto;
width:400px;
font: normal 11px/24px Arial, Helvetica, sans-serif;
color:#e7e7e7;
float:left;
padding-left:10px;
}
.copyrights
{
margin:0 auto;
width:280px;
font: normal 11px/24px Arial, Helvetica, sans-serif;
color:#e7e7e7;
float:right;
}
#fotter a
{
color:#d9aa6d;
text-decoration:none;
}
#fotter a:hover
{
color:#f6ff00;
text-decoration:underline;
}
/*---------------table property-------------------*/
.singleBorder{
    border:1px #d6d6d6 solid;
    background-color:#f6f6f6;
}
.singleBorder td{
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
    font-weight:bold;
    color:#333333;
}
.singleBorder input,select{
    border:1px #aaaacc solid;
    font-family:tahoma;
    font-size:12px;
    font-weight:normal;
    padding:2px;
    background-color:#FFFFFF;
}
.singleBorder input:focus{  /* doesn't work in IE 5,6 */
    border:1px #aaaacc solid;
    font-family:tahoma;
    font-size:12px;
    font-weight:normal;
    padding:2px;
    background-color:#FFFF99;
}
.points{
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
    color:#999999;
    font-weight:normal;
    padding:30px;
}
.formHeading{
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:22px;
    font-weight:bold;
    color:#0066CC;
    padding:10px;
    text-shadow:#FF3333 .2em .2em .2em;
}www.aryantech.in

Thursday, 25 April 2013

Import Capchya In JSp



Capchya.jsp


<%@ page import="nl.captcha.Captcha"%>

<%
Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);
request.setCharacterEncoding("UTF-8");
String answer = request.getParameter("answer");
if (captcha.isCorrect(answer))
{
%>
<b>Correct Captcha Code !</b> <%
  } else {
 %> <b>In Correct Captcha Code !</b> <%
  }
 %>




Sample.jsp


<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Simple CAPTCHA Exampe</title>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>
<body>
<center>
<h3>Simple CAPTCHA Example</h3>
<img id="captcha" src="<c:url value="simpleCaptcha.jpg"  />" width="150">
<form action="captchasubmit.jsp" method="post">
<input type="text" name="answer" /><br>
<input type="submit" value="Submit"></form>
</center>
</body>
</html>


Aryantech India

Wednesday, 24 April 2013

JAVA MVC



Java MVC ( Model View Controller ) Design Pattern

Model View controller is a classical design pattern used in applications who needs a clean separation between their business logic and view who represents data.Aryantech Pune


LoginBean.java

package one;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;



public class LoginBean {
private static final long serialVersionUID = 1L;
 

Connection con;
PreparedStatement pst;
ResultSet rs;

    public LoginBean() {
    try
    {
 
  Class.forName("com.mysql.jdbc.Driver");

     con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","ims");

 
   }
    catch (Exception e)
    {
    e.printStackTrace();
    }
     
    }
 
 
    public  String checkLogin(String uname,String psw)
{
String status="";

try
{
pst=con.prepareStatement("select username,password from registration where username=? and password=?");
pst.setString(1,uname);
pst.setString(2,psw);

rs=pst.executeQuery();


boolean b=false;

b=rs.next();

if(b==true)
{
status="success";
}
else
{
status="fail";
}

}

catch (Exception exx)
{
exx.printStackTrace();

}
return status;
}



   



public String register(int n,String user,String add,int m,String pass)
{


System.out.println("name"+user);
 System.out.println("name"+add);
String status1="";

try
{
pst=con.prepareStatement("insert into registration values(?,?,?,?,?)");
pst.setInt(1,n);
pst.setString(2,user);
pst.setString(3,add);
pst.setInt(4,m);
pst.setString(5,pass);
     
  int i=pst.executeUpdate();


  if(i==1)
{

status1="success";
  }
  else
{
  status1="false";
  }

}
catch (Exception w)
{
w.printStackTrace();
}
return status1;
}

}





LoginServlet.java

package one;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet("/done")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<body bgcolor='gray'>");

String uname=request.getParameter("uname");
String psw=request.getParameter("psw");
boolean b=false;
try
{

LoginBean lb=new LoginBean();

String status=lb.checkLogin(uname,psw);

if(status.equals("success"))
{
out.println("<h1> welcome to AryanTech</h1>");
out.println("<h1>You Are Registered Person</h1>");

}
else
{
//out.println("<h2> invalid username and password</h2>"); ;
//out.println("<A href=login.jsp>Try again</A>");
response.sendRedirect("Login.jsp?msg=Invalid Username or Password");
//String message="No user or password matched" ;
  // response.sendRedirect("login.jsp?error="+message);
   //response.sendRedirect("Login.jsp");
}
 
}
catch (Exception es)
{
es.printStackTrace();
}
out.println("</body>");
out.println("</html>");

out.close();
}
}


Tuesday, 23 April 2013

Database modification Using JSp


<%@page import="java.sql.*" %>

 
<%!
Connection con;
PreparedStatement pst;
ResultSet rs;
String reg1=null;
String nm=null;
String add=null;


%>

<%

try
{

Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","ims");


}
catch(SQLException e)
{

e.printStackTrace();
}


String sb=request.getParameter("s1");



if(sb.equals("Update"))

{
int id1=Integer.parseInt(request.getParameter("id"));
String user=request.getParameter("user");
String add=request.getParameter("add");
     String email=request.getParameter("email");
String   contact=request.getParameter("contact");



try
{

String query="update customer set name=?,address=?,email=?,contact=? where customer_id=?";
pst=con.prepareStatement(query);



 pst.setString(1,user);
 pst.setString(2,add);
 pst.setString(3,email);
 pst.setString(4,contact);
 pst.setInt(5,id1);

 int i=pst.executeUpdate();

 if(i>0)
 {
%>
<h1>Updated</h1>
<%

 }
 else
 {
%>
<h1>Not Updated</h1>
<%
 }




}
catch(Exception ex)
{

}
}


//for delete
 if(sb.equals("Delete"))
{
try
{
int id1=Integer.parseInt(request.getParameter("id"));
pst=con.prepareStatement("delete from  customer where  customer_id=?");

//int id=Integer.parseInt(request.getParameter("c1"));

out.println(id1);

pst.setInt(1,id1);
int i=pst.executeUpdate();


if(i>0)
{
out.println(i+ "Record Deleted");
}
else
{
out.println("problem");
}


}
catch(Exception ex)
{

}
}
else
{}
%>Aryantech India Pune
Best IT Traning Institute

Monday, 22 April 2013

Java Script Basic

Basic program to display Current Date & Time using Java Script.



AryanTech India


<html>
<head>
<script>
function displayDate()
{
document.getElementById("demo").innerHTML=Date();
}
</script>
</head>
<body>

<h1>My First JavaScript</h1>
<p id="demo">This is a paragraph.</p>

<button type="button" onclick="displayDate()">Display Date</button>

</body>
</html>


Best IT  Traning  Institute in  Maharastra

Saturday, 20 April 2013

Html Validation Using JQuery



Simple and Effective validation using JQuery.Here you can easy lern the validation by using jQuery JQuery with java script.






Validation.html

Aryantech India,Pune


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>textbox to accept only numbers (digits)</title>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
 <script type="text/javascript" src="jquery.validate.js"></script>
<script type="text/javascript">

$(document).ready(function(){
 
   //called when key is pressed in textbox
$("#quantity").keypress(function (e)
{
$("#errmsg").hide();
 //if the letter is not digit then display error and don't type anything
 if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57))
 {
//display error message
$("#errmsg").html("&nbsp;&nbsp;Digits Only").show();
  return false;
      }
 });
 $('#quantity').blur(function(a) {
 if((parseInt($("#quantity").val(), 10)<18))
 {
      $("#errmsg").html("&nbsp;&nbsp;Age must be greater than 18").show();

 }
 if((parseInt($("#quantity").val(), 10)>35))
 {
      $("#errmsg").html("&nbsp;&nbsp;Age must be less than 35").show();
 }
});
    //FOR EMAIL ADDRESS
$("#form").validate({
        rules: {
          name: "required",// simple rule, converted to {required:true}
          email: {// compound rule
          required: true,
          email: true
        },
        url: {
          url: true
        },
        comment: {
          required: true
        }
        },
        messages: {
          comment: "Please enter a comment."
        }
      });
});
  </script>
<style type="text/css">
    * { font-family: Verdana; font-size: 11px; line-height: 14px; }
    .submit { margin-left: 125px; margin-top: 10px;}
    .label { display: block; float: left; width: 120px; text-align: right; margin-right: 5px; }
    .form-row { padding: 10px 0; clear: both; width: 800px; }
    label.error { width: 250px; display: block; float: left; padding-left: 10px; }
    input[type=text], textarea { width: 250px; float: left; }
    textarea { height: 50px; }
  </style>
</head>
<body>
   <h3><font color="blue">Please enter the following information</font></h3>
 
  <form id="form" method="post" action="formValidation.jsp">
      <div class="form-row"><span class="label">Name *</span><input type="text" name="name" id="namei"/></div>
      <div class="form-row"><span class="label">E-Mail *</span><input type="text" name="email" id="emaili"/></div>

      <div class="form-row"><span class="label">URL</span><input type="text" name="url" id="urli" /></div>
 <div class="form-row"><span class="label">Age</span><input type="text" name="quantity" id="quantity" /></div>
 <div class="label.error" id="errmsg"></div>
      <div class="form-row"><span class="label">Your comment *</span><textarea name="comment" id="commenti"></textarea></div>
      <div class="form-row"><input class="submit" type="submit" value="Submit" name="submit" id="submiti"></div>
    </form>
</body>
</html>


Just Save It and Run it...................!
Best Traning Institute

Friday, 19 April 2013

Send Email Using JSP




Here is an example to send an HTML email from your machine. Here it is assumed that your localhostis connected to the internet and capable enough to send an email.
This example is very similar to previous one, except here we are using setContent() method to set content whose second argument is "text/html" to specify that the HTML content is included in the message.


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import="java.sql.*,java.util.*,javax.activation.*"%>
<html>
<body bgcolor=lightblue>
<center>
<div style="color:navy;background-color:white;font:700 16pt arial">Forgot Password
</div>
<form action="forgotpassword.jsp" method="post">
Enter your email address
<input type=text name=email
   size=40>
<p>
<input type=submit value="Submit">
&nbsp;
<input type=button onclick="javascript:history.back()" value="Back">
</form>

<%
  String  email = request.getParameter("email");
  if ( email  == null ) return;

  Connection con = null;
  Statement  st  = null;
  ResultSet rs = null;
 try
 {
 // con = user.getConnection();
  st =  con.createStatement();
  rs = st.executeQuery("select uname, pwd from users where email = '"  + email + "'");

   if ( ! rs.next() )
  {
      out.println("Sorry! Email Address Not Found In Our Database. <p><a href=login.html>Login Page</a>");
      return;
   }

   String   un = rs.getString("uname");
   String   pwd = rs.getString("pwd");
   String body = "Dear Subscriber, <p>Use the following details to login.<p>Username : " + un + "<p>Password:"+ pwd + "<p>Webmaster,<br>javajobs.com";
   Properties props = System.getProperties();
  // Session msession = Session.getDefaultInstance(props, null);
 //  Message msg = new MimeMessage(msession);
  // msg.setFrom(new InternetAddress("webmaster"));
   //msg.setRecipient(Message.RecipientType.TO,
     // new InternetAddress(email));
  //msg.setDataHandler(
         //   new DataHandler(body,"text/html"));
  //msg.setSubject("Account Information");
   // send message
 // Transport.send(msg);Aryantech Pune
  out.println("Account details are sent to email address. Please use those details to login.<p> <a href=login.html>Login Page</a>");
  } // end of try
  catch ( Exception ex)
 {
     out.println("Sorry! Error : " + ex.getMessage() + "<p> <a href=login.html>Login Page</a>");
  }
 finally
{
    rs.close();
    st.close();
    con.close();
 }
%>
</body>
</html>
Aryantech Pune


Thursday, 18 April 2013

JQuery With Dropdown list


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
    <title>jQuery Dropdown Checkbox List</title>
    <link rel="stylesheet" type="text/css" href="css/ui.dropdownchecklist.css" />
    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <script type="text/javascript" src="jquery/jquery.js"></script>
    <script type="text/javascript" src="jquery/ui.core.js"></script>
    <script type="text/javascript" src="jquery/ui.dropdownchecklist.js"></script>
    <script type="text/javascript">
     $(document).ready(function(){
    $("#s5").dropdownchecklist({ firstItemChecksAll: true, maxDropHeight: 100 });
     });
    </script>
 </head>
<body>
 <h1 align="center" >jQuery Dropdown Checkbox List</h1>
 <form action="dropdown_checkboxresult.jsp" method="post" >
  <table align="center">
   <tr>
    <td>Select Product :</td>
    <td>
     <select id="s5" multiple="multiple" name="dropdown" >
       <option>All</option>
       <option>Product 1</option>
       <option>Product 2</option>
       <option>Product 3</option>
       <option>Product 4</option>
       <option>Product 5</option>
       <option>Product 6</option>
       <option>Product 7</option>
       <option>Product 8</option>
       <option>Product 9</option>
       <option>Product 10</option>
       <option>Product 11</option>      
       <option>Product 12</option>
       <option>Product 13</option>
       <option>Product 14</option>
       <option>Product 15</option>
       <option>Product 16</option>
       <option>Product 17</option>
       <option>Product 18</option>
       <option>Product 19</option>
       <option>Product 20</option>        
     </select>
    </td>
   </tr>
   <tr>
    <td></td>
    <td><input type="submit" value="Submit" /></td>
   </tr>
  </table>
 </form>
</body>
</html>AryanTech Pune
Best Traning Institute.

Jquery Basic

Aryantech Pune
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>AryanTech</title>
</head>
<body>
  <h2 align="center">Selected Product Details</h2>
  <hr width=300 >
 <%
  String [] dropdownValues = request.getParameterValues("dropdown");
  int count=1;
  if(dropdownValues!=null){
 %>
  <table align="center" >
    <tr>
     <th>S.No.</th>
     <th>Product Name</th>
    </tr>  
 <%
   for(int i = 0; i < dropdownValues.length; i++){
if(!dropdownValues[i].equals("All")){  
 %>
   <tr>
     <td>
        <% out.println(""+count+" . "); %>
     </td>
     <td>
        <% out.println(dropdownValues[i]); %>
     </td>
   </tr>
 <%
    count++;
  }
}
 %>
   </table>
Best Traning Institute .
 <% }else{ %>
    <table align="center" >
      <tr>
        <td><% out.println("You not select any Product."); %></td>
      </tr>
    </table>
 <% } %>
</body>
</html>

Monday, 15 April 2013

Spring Framwork


Spring Framework Tutorial

Spring framework is an open source Java platform that provides comprehensive infrastructure support for developing robust Java applications very easily and very rapidly.
Spring framework was initially written by Rod Johnson and was first released under the Apache 2.0 license in June 2003.
This tutorial has been written based on Spring Framework version 3.1.0 released in Dec 2011.

Audience

This tutorial is designed for Java programmers with a need to understand the Spring framework in detail along with its architecture and actual usage. This tutorial will bring you at intermediate level of expertise from where you can take yourself at higher level of expertise.

Prerequisites

Before proceeding with this tutorial you should have a good understanding of Java programming language. A basic understanding of Eclipse IDE is also required because all the examples have been compiled using Eclipse IDE.

Benefits of Using Spring Framework:

Following is the list of few of the great benefits of using Spring Framework:
  • Spring enables developers to develop enterprise-class applications using POJOs. The benefit of using only POJOs is that you do not need an EJB container product such as an application server but you have the option of using only a robust servlet container such as Tomcat or some commercial product.
  • Spring is organized in a modular fashion. Even though the number of packages and classes are substantial, you have to worry only about ones you need and ignore the rest.
  • Spring does not reinvent the wheel instead, it truly makes use of some of the existing technologies like several ORM frameworks, logging frameworks, JEE, Quartz and JDK timers, other view technologies.
  • Testing an application written with Spring is simple because environment-dependent code is moved into this framework. Furthermore, by using JavaBean-style POJOs, it becomes easier to use dependency injection for injecting test data.
  • Spring's web framework is a well-designed web MVC framework, which provides a great alternative to web frameworks such as Struts or other over engineered or less popular web frameworks.
  • Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions.
  • Lightweight IoC containers tend to be lightweight, especially when compared to EJB containers, for example. This is beneficial for developing and deploying applications on computers with limited memory and CPU resources.
  • Spring provides a consistent transaction management interface that can scale down to a local transaction (using a single database, for example) and scale up to global transactions (using JTA, for example).Aryantech India pvt ltd

Saturday, 13 April 2013

Set Location On google map Using Jsp


<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>

<script>
function initialize()
{
var mapProp = {
  center:new google.maps.LatLng(51.508742,-0.120850),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:300px;height:300px;"></div>

Name:< input>
<h1>Set Your Location On Map</h1>
</body>
</html>

Ajax application using Jsp Servlet


<html><head>
<title>Binod Java Solution AJAX </title>
<script type="text/javascript">
var request; function getName(){
var roll = document.getElementById("roll").value;
var url = "http://localhost:8080/blog_demo/StudentInfo?roll="+roll;
if(window.ActiveXObject){ request = new ActiveXObject("Microsoft.XMLHTTP"); }
else if(window.XMLHttpRequest){ request = new XMLHttpRequest(); } request.onreadystatechange = showResult;
request.open("POST",url,true);
request.send();
}
function showResult(){
if(request.readyState == 4){
var response = request.responseXML;
var students = response.getElementsByTagName("Student");
var student = students[0];
document.getElementById("NamelH1").innerHTML = student.getElementsByTagName("Name")[0].text;
document.getElementById("HostelH1").innerHTML = student.getElementsByTagName("Hostel")[0].text;
document.getElementById("ContactH1").innerHTML = student.getElementsByTagName("Contact")[0].text;
}
}
</script>
</head>
<body><h2> GET STUDENT INFO </h2>
<br> Enter Roll Number <input type="text" id="roll">
<input type="button" value="Get Name" onclick="getName();"/>
<br> Name : <span id="NamelH1"></span> <br
> Hostel : <span id="HostelH1"></span> <br
> Contact : <span id="ContactH1"></span> <br>
</body>
</html>Aryantech Pune

Login Usecase Using Jsp & mysql


<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 100% }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions =true
        {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
     
     
     
      function loadScript() {
     var script = document.createElement("script");
     script.type = "text/javascript";
     script.src = "http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=TRUE_OR_FALSE&callback=initialize";
     document.body.appendChild(script);
    }

    window.onload = loadScript;
     
    </script>
  </head>
  <body onload="initialize()">
    <div id="map-canvas"/>
  </body>
</html>Aryantech pune

Insert Google map on jsp page

Map.jsp



<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 100% }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=false">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions =true
        {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
     
     
     
      function loadScript() {
     var script = document.createElement("script");
     script.type = "text/javascript";
     script.src = "http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=TRUE_OR_FALSE&callback=initialize";
     document.body.appendChild(script);
    }

    window.onload = loadScript;
     
    </script>
  </head>
  <body onload="initialize()">
    <div id="map-canvas"/>
  </body>
</html>Aryantech India,pune

Insert date Into Mysql database using jsp


Date.jsp

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form action="show.jsp" method="post">
        <table border="1" bgcolor="pink" bordercolor="green">
        <tr>
        <td>Name:<input type="text" name="name"/></td>
        </tr>
        <tr>
     
       <td>Select Date: (YYYY)</td><td><select name="year">
       <option value="">--Select--</option>
       <option value="1990">1990</option>
       <option value="1991">1991</option>
       <option value="1992">1992</option>
       <option value="1993">1993</option> </select></td>
     
     
       <td>MM</td><td><select name="month">
       <option value="">--Select--</option>
       <option value="01">jan</option>
       <option value="02">Feb</option>
       <option value="03">March</option>
       <option value="04">April</option> </select></td>
     
     
       <td>DD</td><td><select name="day">
       <option value="">--Select--</option>
       <option value="01">01</option>
       <option value="02">02</option>
       <option value="03">03</option>
       <option value="04">04</option>
       <option value="05">05</option>
       <option value="06">06</option>
       <option value="07">07</option>
       <option value="08">08</option>
       <option value="09">09</option></select></td>
     
       </tr>
       <tr>
       <td colspan="6" align="center"><input type="submit" name="submit" value="submit"/></td>
       </tr>
       </form>
     
    </body>
</html>



Show.jsp

<%@page import="java.text.SimpleDateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*,java.util.*,java.text.*"%>
<%

String nm=request.getParameter("name");
    String year=request.getParameter("year");
    String month=request.getParameter("month");
    String day=request.getParameter("day");
   
    String ddd=year+"/"+month+"/"+day;
   
    //String d1=year+month+day;
   
    out.println("year is"+year);
    out.println("name  is"+nm);
   
   //java.sql.Date date=new java.sql.Date(0000-00-00);
   
 
    try {
    Class.forName("com.mysql.jdbc.Driver");

     Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","ims");
   
    PreparedStatement ps=con.prepareStatement("insert into tbl_date(name,DOB) values(?,?)");
    ps.setString(1,nm);
    //ps.setDate(2,date.valueOf(d1));
   ps.setString(2,ddd);
   
    int i=ps.executeUpdate();
    if(i==1)
               {
        out.println("Date success");
    }
    else
    {
    out.println("problem while inserting");  
    }
}
catch(Exception e)
               {
    out.println(" "+e.getMessage());
}

%>  Aryantech pune


Tuesday, 9 April 2013

Retrive Image From Mysql Database in JSP


<%@ page import="java.sql.*,java.io.*,java.util.*" %>
<HTML>
 <table border="1" bgcolor="olive" align="center" width=250">
 <tr><th>Name</th><th>Address</th><th>Image</th><th>Logo</th></tr>
   <%
  try{    
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","ims");
    Statement stmt=con.createStatement();
    String strQuery = "select * from photoinfo";
    ResultSet rs = stmt.executeQuery(strQuery);
    while(rs.next())
    {
   
   
     
       %>
      <tr>
      <td bgcolor="silver"><%=rs.getString("name")%></td>
      <td bgcolor="silver"><%=rs.getString("address")%></td>
   
      <td align="center"  bgcolor="silver">

<img src="image.jsp?imgid=<%=rs.getInt(1)%>" width="100" height="50">

</td>
<td>
<img src="image1.jsp?id=<%=rs.getInt(6)%>" width="100" height="50">
</td>
      </tr>
      <%
    }
    rs.close();
    con.close();
    stmt.close();
  }
  catch(Exception e)
  {
    e.getMessage();
  }
  %>
 </table>
</HTML>







Image.jsp







<%@ page import="java.sql.*,java.io.*,java.util.*" %>
<%
  int id =  Integer.parseInt(request.getParameter("imgid"));
  try{    
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","ims");    
    Statement st=con.createStatement();
    String strQuery = "select photo from photoinfo where id="+id;
    ResultSet rs = st.executeQuery(strQuery);

    String imgLen="";
   while(rs.next()){
      imgLen = rs.getString(1);
       }
    rs = st.executeQuery(strQuery);
    if(rs.next()){
      int len = imgLen.length();
      byte [] rb = new byte[len];
      response.setContentType("image/png");
      InputStream readImg = rs.getBinaryStream(1);
      //InputStream readImg1 = rs.getBinaryStream(2);
      int index=readImg.read(rb, 0, len);
      st.close();
      response.reset();
      response.getOutputStream().write(rb,0,len);
      response.getOutputStream().flush();
     
     
     
     
    }
  }
  catch (Exception e){
    e.printStackTrace();
  }
%>AryanTechindia pvt.ltd


Saturday, 6 April 2013

Generate Reports in jsp


if(sb.equals("Get Details.."))

{
%>
<html>
<body bgcolor="rgb(225,255,150)">
<center><h1>Customer Reports</h1></center>
<table border="1" bordercolor="red" align=center bgcolor="#525678" margin="1">

<tr >
<td>
<th bgcolor="silver"><h3>Cutomer Id</h3></th>
<th bgcolor="silver"><h3>Cutomer Name</h3></th>
<th bgcolor="silver"><h3>Cutomer Address</h3></th>
<th bgcolor="silver"><h3>Cutomer Email</h3></th>
<th bgcolor="silver"><h3>Cutomer Contact</h3></th>
<th bgcolor="silver"><h3>Select</h3></th>
<th bgcolor="silver"><h3>Edit</h3></th>
<th bgcolor="silver"><h3>Delete</h3></th>


<%
try
{
pst=con.prepareStatement("select * from customer order by customer_id");  
}
catch (SQLException ex)
{
out.println("Exception"+ex.getMessage());
}
   
rs=pst.executeQuery();
while(rs.next())
{


id=rs.getInt(1);
out.println(id);

HttpSession s12=request.getSession();
s12.setAttribute("name",id);

nm=rs.getString(2);
out.println(nm);
session.setAttribute("name",nm);
%>
<form action="edit.jsp" method="post" name="f1">
<tr><td></td>
<td><font color="" size="4"><%= rs.getInt(1)%></td>


<td><font color="" size="4"><%= rs.getString(2)%></td>

<td><font color="" size="4"><a href=<%= rs.getString(6)%>> <%= rs.getString(3)%></a></td>

<td><font color="" size="4"><%= rs.getString(4)%></td>

<td><font color="" size="4"><%= rs.getString(5)%></td>

<td><input type="checkbox" name="c1" value="<%=id %>" id="c1"></td>
<td><input type="submit" name="s1" value="Edit" onClick="return chek(this.form);"></td>
<td><a href="delete.jsp"><img src="img/delete1.png" height="40" width="40" ></a></td>
</tr>
</form>

<%
}

 %>
 </table>

 <%
  }