Posts

Showing posts from April, 2015

HTML PDF Upload and preview option

Image
<!----   To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. @author: ananddw --> <!DOCTYPE html>   <html lang="en">     <head> <body BGCOLOR=#66CCFF>         <title>Java by Anand</title>         <script type="text/javascript" src="http://ajax.googleapis .com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>         <script type="text/javascript">             function PreviewImage() {                 pdffile=document.getElementById("uploadPDF").files[0];                 pdffile_url=URL.createObjectURL(pdffile);                 $('#viewer').attr('src',pdffile_url);  ...

DropDown value Comes on Text Field Using HTML and JS

<html> <head> <body bgcolor="#3399FF"> <center> <h2>DropDown value on Text Field</h2> <b>Select Value:</b><select id="DP" onchange="run()">       <!--Call run() function-->      <option>-select-</option>      <option value=     "value of 1 value of 1 value of 1 value of 1      value of 1 value of 1 value of 1 value of 1      value of 1 value of 1 value of 1 value of 1      value of 1 value of 1 value of 1 value of 1      value of 1 value of 1 value of 1 value of 1" title="value of 1" ">1</option>      <option value="value of 2" title="value of 2">2</option>      <option value="value of 3" title="value of 3">3</option>      <option value="value of 4" title="valu...

Why mapping Used in Java

Basically Mapping will configure on xml because of following reason. > When we use multiple file on different package then that time server doesn't decide which file we execute. > on XML we define full controlling path . like if i click on ___ Control will forward to ___- page  > On html form tag we define form action = --- so that is called xml and find where class has been define if find then perform operation else get error  Hope this will help  Thanks  

Use Of PageContext() Method in Servlet Java

basically it is used to find attribute and set Attribute value on servlet :- please find example built on your platform but please put all the file under WEB-Pages .else you will get Error :- Request resource not available ============ index.html=================== <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title> User Login Page – Enter details</title> </head> <body> <form action="validation.jsp"> Enter User-Id: <input type="text" name="uid"><br> Enter Password: <input type="text" name="upass"><br> <input type="submit" value="Login"> </form> </body> </html> =========== validation.jsp================= <%--     Document   : vali...

How to work Equals() and EqualsIgnoreCase() method in java

Equals():-To compare two strings for equality. EqualsIgnoreCase():-The comparison is case-sensitive String if both are same return boolean value= true =========Equals.java=============== /**  *  * @author Ananddw  */ public class Equals {     public static void main(String[] args) {         String str1 = "Anand";         String str2 = "anand";         String str3 = "Ajeet";         String str4 = "Antrish";         // Calling equals method         System.out.println("Compare str1 and str2 with equals method===>" + str1.equals(str2));         System.out.println("Compare str1 and str3 with equals method===>" + str1.equals(str3));         System.out.println("Compare str3 and ...

Registration form Using HTMl and CSS

<!DOCTYPE html> <!--  * @author ananddw --> <html>     <body>         <form autocomplete="off" action="Test.html">             <h3> Registration form by Anand</h3> </br> </br>             <!----  For FullName ---->             FullName:<input type="text" name="FullName" placeholder=" Your Full Name" required /> </br> </br>             <!----  For Email: ---->             Email:<input type="email" name="Email" placeholder="Type Email @gmail.com"  required/> </br> </br>             <!----...

Get The longText Dropdown value using hover and alert function

<!DOCTYPE html> <!--  Author     : ananddw --> <html><body bgcolor="gray"><center>         <h1>welcome</h1>         <h2>Add Enquiry Form</h2>         <table>             <tr><td></td>                 <td><select id="short_code" onchange="getSelected(this)">                         <option value="Select">-Select-</option>                         <option value="Value of DropDown 1 Value of DropDown 1 Val...

How to Call Hover() form HTML page to getting the value of Dropdown onmousehover...

Image
Inside a option value if you write tittle="Value of Dropdown1" and the name of Dropdown is "1" . So when you mousehover on 1 it should display "value of dropdown 1".. Please find updated code =====================register.html====================== <html><body bgcolor="gray"><center> <h1>welcome</h1> <h2>Add Enquiry Form</h2> <table> </tr> <tr><td></td> <td><select name="timings"> <option value="Select">-Select-</option> <option value="DROPDOWN 1 " title="Value of DropDown 1">1 </option> <option value="DROPDOWN 2" title="Value of DropDown 2">2</option> <option value="DROPDOWN 3" title="Value of DropDown 3">3</option> <option value="DROPDOWN 1 " title="Value of DropDown 4">4 </option> ...

How to populate Drop Down From Database Table in Java

Image
Before create project you have to understand from a JSP file you have to create JDBC Connection with default port 3306  and call HTML Code inside JSP page :-- ==========================index.jsp==================================== <%@ page import="java.sql.*" %> <%ResultSet resultset =null;%> <HTML> <HEAD>     <TITLE>Welcome in Java by Anand,Bangalore</TITLE> </HEAD> <BODY BGCOLOR=#66CCFF> <% Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/Anand"; con = DriverManager.getConnection(url, "root", "pass@123");     Statement statement = con.createStatement() ;     resultset =statement.executeQuery("select * from blore") ; %>       <center>     <h1> Welcome in Java by Anand,Bangalore</h1>         <select>         <...

Simple Login Form With Servlet Forwarding

For Creating a login form with Servlet we have require some files For fornt End:-index.html For Forwarding control: Demo.java (Create as a servlet not a normal java file) ----- index.html --- <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. @author ananddw --> <html><body>         <form action="welcome" method="get" align="center">                                 Enter your name<input type="text" name="name"> <br>                                     ...

Basic HTML Tag Used

Image
<!----  Author: Anand --> <html>       <head>             <title> Welcome in the World of HTML </title>                    <form align="center">                    <body bgcolor="##33CCFF">            <select name="DropDown">                        <option  id="1"  value="Anand" > Anand </option>                       <option  id="2" value="Antrish" >Antrish </option>                       <option  id="3" value="Ajeet" >Ajeet </option>                 </select>  ...

How to get client IP address in a servlet

package com.anand; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ClientIP extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {      response.setContentType("text/html");      PrintWriter out = response.getWriter();             String name = request.getParameter("name");            System.out.println("Eneter Name : " + name);            System.out.println("IP Address of request : </font></b>" +             request.getRemoteAddr()+"<h3>");  } }  

How to Get Client IP Address Using Java Code

/*  * @author :Anand  */ package com.anand; import java.net.InetAddress; import java.net.UnknownHostException; public class IP{ public static void main(String[] args) {    InetAddress ip;  try {   ip = InetAddress.getLocalHost(); System.out.println("Your IP is====>" + ip.getHostAddress());    } catch (UnknownHostException e) {  System.out.println("catch the exception if Error Come ===>"+e);   e.printStackTrace();    }   }   }

"How to Read file Line by line from your system Using java code "

package com.Anand; /*    * Created by : Anand  * Date: 04-APR-2015         *         */ import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Reader {   public static void main(String[] args) {   try ( BufferedReader br = new BufferedReader(new FileReader("E:\\Anand.txt"))) { System.out.println("Read file ok ===> "+br); String LinebyLine;   while ((LinebyLine = br.readLine()) != null) { System.out.println("Read file Line by line===> "+LinebyLine); }   } catch (IOException e) { e.printStackTrace(); }    }}
Image
 ====================================================================== How to See Total Visitors in webpage Using  HTMl front End and Servlet Used for forwarding the Control ? ======================================================================= For creating this project we need to create Some files like :- index.jsp :- for front page logout.jsp:- for log out page              ________________________________index.jsp________________________________________ <html> <body bgcolor="#FFCCFF"> <h1 align="center">Welcome to the World of java </h1> <table align="right"> <tr> <td> <h4> Total Visited :<%=application.getAttribute("TV") %> </h4></td> </tr> <tr> <td> <h4> Total Active :<%=application.getAttribute("TA") %> </h4></td> </tr> </table> <br /...