<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-544760739631615763</id><updated>2026-04-05T17:46:56.417+05:30</updated><category term="Semester 6"/><category term="Semester 7"/><category term="C"/><category term="JAVA"/><category term="Previous Question Papers"/><category term="Semester 3"/><category term="Compiler Design"/><category term="Semester 4"/><category term="Semester 5"/><category term="Compiler Lab"/><category term="Kannur University"/><category term="C++"/><category term="B-Tech"/><category term="Graphics and Multimedia Lab"/><category term="LEX"/><category term="Internet and Web Programming Lab"/><category term="Programming Environment Lab"/><category term="YACC"/><category term="Semester 8"/><category term="Assembly Language"/><category term="Hardware Lab"/><category term="MASM"/><category term="Network-DBMS Lab"/><category term="Client-Server"/><category term="Datastructure"/><category term="Ebook Collection"/><category term="LISP"/><category term="Internet and Web Programming with Java"/><category term="Java Swings"/><category term="Sort"/><category term="Operating Systems"/><category term="PHP"/><category term="Recruitment"/><category term="S8 Qstns"/><category term="Web Designing"/><category term="Web Programming"/><category term="Aptitude Questions"/><category term="Internet and Web Programming"/><category term="NetBeans"/><category term="Oracle"/><category term="Systems Lab"/><category term="php examples"/><category term="Parser"/><category term="String"/><category term="TCP"/><category term="GTC"/><category term="Graph Theory and Combinatorics"/><category term="Java awt"/><category term="Computer Graphics and Multimedia"/><category term="DCCN"/><category term="Label"/><category term="Presentation Slides"/><category term="GTC questions"/><category term="Graph Theory and Combinatorics Questions"/><category term="Matrix"/><category term="MySQL"/><category term="2009"/><category term="CD"/><category term="Computer Graphics"/><category term="Palindrome"/><category term="UDP"/><category term="2011"/><category term="2012 Questions"/><category term="Compiler Questions"/><category term="Count"/><category term="Data Communication and Computer Networks"/><category term="Ebooks s7"/><category term="Eclipse"/><category term="Factorial"/><category term="Fibonacci"/><category term="File"/><category term="Intermediate Code Generator"/><category term="Prime"/><category term="Results"/><category term="Reverse"/><category term="Syllabus"/><category term="2010"/><category term="ACA"/><category term="Addition"/><category term="Advanced Computer Architecture"/><category term="Assignments"/><category term="Behrouz A. Forouzan"/><category term="Bubblesort"/><category term="CNS"/><category term="Circle Drawing"/><category term="Cryptography and Network Security"/><category term="Data Base Management Systems"/><category term="Form"/><category term="Inter Process Communication"/><category term="JList"/><category term="Line Drawing"/><category term="Log In Example"/><category term="Miniproject"/><category term="Substring Search Replacement"/><category term="Taylor Series"/><category term="Temperature Conversion"/><category term="WHILE"/><category term="Written English Aptitude Questions"/><category term="ai"/><category term="ebook s5"/><category term="Apache Tomcat"/><category term="Artificial Intelligence"/><category term="Baseconversion"/><category term="Basic Computer Knowledge Aptitude"/><category term="DBMS"/><category term="Databases"/><category term="Distributed Computing"/><category term="Ebook 6"/><category term="File Transfer Protocol"/><category term="HTML"/><category term="IF-THEN-ELSE"/><category term="Inheritance"/><category term="JOptionPane"/><category term="Largest"/><category term="LinkedList"/><category term="OR"/><category term="Operations Research"/><category term="Semester 1-2"/><category term="Software Engineering"/><category term="Software Engineering Aptitude"/><category term="Stack"/><category term="Towers of Hanoi"/><category term="semaphore"/><category term="thread"/><category term="2K6CS604"/><category term="ATA"/><category term="Advanced Topics in Algorithms"/><category term="Arithmetic Expression"/><category term="Array"/><category term="Beep"/><category term="Binarysearch"/><category term="CGM Video Tutorials"/><category term="COD"/><category term="Changecase"/><category term="Cohen-Sutherland Line Clipping"/><category term="Comment Removal"/><category term="Computer Networking"/><category term="Computer Organization and Design"/><category term="Computer Science and Engg."/><category term="DC"/><category term="DO WHILE"/><category term="Data Base Management Systems Questions"/><category term="Data Communication and Computer Networks Questions"/><category term="Design and Analysis of Algorithms"/><category term="Digit to word"/><category term="Distributed Computing Questions"/><category term="EEDM"/><category term="Electric Circuits and Systems"/><category term="Engineering"/><category term="Environmental Engg. and Disaster Management"/><category term="Expression Evaluation"/><category term="FTP"/><category term="For Loop"/><category term="Function Definition"/><category term="Heapsort"/><category term="Imob"/><category term="Infix to Postfix Expression"/><category term="Insertionsort"/><category term="Internet and Mobile Communication System Technologies"/><category term="Iterative"/><category term="J2EE"/><category term="JAVASCRIPT"/><category term="JFileChooser"/><category term="JMenu"/><category term="JProgressBar"/><category term="Line Clipping"/><category term="Linearsearch"/><category term="Mergesort"/><category term="Mobile Communication"/><category term="Notes"/><category term="Odd-Even"/><category term="Operator Overloading"/><category term="Ppt slides 6"/><category term="Producer Consumer Problem"/><category term="Quicksort"/><category term="Recursion"/><category term="Registration Form Validation"/><category term="Rotation"/><category term="S8 Notes"/><category term="SE"/><category term="SP"/><category term="SQL Queries"/><category term="SWITCH"/><category term="Scaling"/><category term="Scheduling"/><category term="Schiller.J"/><category term="Search"/><category term="Selectionsort"/><category term="Shared Memory"/><category term="Stored Procedure"/><category term="String Sort"/><category term="Struts"/><category term="Struts 1.3"/><category term="Student Record"/><category term="Sum of digit"/><category term="Systems Programming"/><category term="TCP Chat"/><category term="TFC"/><category term="Theoretical foundation of  Computation"/><category term="Translation"/><category term="UDP Chat"/><category term="Video Tutorials"/><category term="clisp"/><category term="pipe"/><category term="2D Transformations"/><category term="2K6CS401"/><category term="2K6CS402"/><category term="2K6CS403"/><category term="2K6CS404"/><category term="2K6CS405"/><category term="2K6CS406"/><category term="2K6CS501"/><category term="2K6CS502"/><category term="2K6CS503"/><category term="2K6CS505"/><category term="2K6CS506"/><category term="2K6CS601"/><category term="2K6CS602"/><category term="2K6CS603"/><category term="2K6CS605"/><category term="2K6CS606"/><category term="2K8CSE"/><category term="3D Transformations"/><category term="AC Bridges"/><category term="ACA Questions"/><category term="AI Questions"/><category term="ASCII"/><category term="ATA Questions"/><category term="Abundant Numbers"/><category term="Adb questions"/><category term="Advanced Database Systems"/><category term="Aho A Ravi Sethi and J D Ullman"/><category term="Alert"/><category term="Application Layer"/><category term="Armstrong Number"/><category term="Attention to Detail Section"/><category term="BFS"/><category term="Bank Software"/><category term="Bankers Algorithm"/><category term="Binary Search Tree"/><category term="Biodiversity Conservation"/><category term="Bridges"/><category term="CNS Questions"/><category term="Calculator"/><category term="Cgm Questions"/><category term="Chaining"/><category term="Checkbox (awt)"/><category term="Colour Generator"/><category term="Compilers Principles Techniques and Tools"/><category term="Concatenation"/><category term="Cookie"/><category term="Corman T H -Lieserson C E - Rivest R L"/><category term="Cosx"/><category term="D3 js"/><category term="DDA Line Drawing"/><category term="DNS"/><category term="DSA"/><category term="Daa"/><category term="Daa questions"/><category term="Data Communications and Networking"/><category term="Data Structures and Algorithms"/><category term="Data Visualisation"/><category term="Data communication and Networking"/><category term="Database System Concepts"/><category term="Deadlock"/><category term="Decimal to Hexadecimal"/><category term="Desk Calculator"/><category term="Dining-Philosopher"/><category term="Discrete and Combinatorial Mathematics"/><category term="Domain Name Server"/><category term="DoublyLinkedList"/><category term="Drawing"/><category term="E-Tendering"/><category term="EBM"/><category term="EM"/><category term="Ebook (4)"/><category term="Echo"/><category term="Echo Server"/><category term="Economics and Business Management"/><category term="Ecosystems"/><category term="Electrical"/><category term="Elimination of Multiple Spaces Tabs Emptylines"/><category term="Ellipse"/><category term="Engineering Mathematics"/><category term="Engineering Mathematics III"/><category term="Engineering Mathematics IV"/><category term="FCFS"/><category term="FOREACH"/><category term="File Copier"/><category term="Finite Automata"/><category term="Floating Point and Integers"/><category term="Font"/><category term="GCD"/><category term="Generate Index"/><category term="Grimaldi R P"/><category term="Hall Ticket"/><category term="Hashing"/><category term="Helically Printing"/><category term="IT Reasoning"/><category term="Ian Sommerville"/><category term="Image (awt)"/><category term="Imob questions"/><category term="Interface"/><category term="Introduction to Algorithms"/><category term="Introduction to Automata Theory - Languages and Computations"/><category term="Iw questions"/><category term="J.E. Hopcroft"/><category term="JAVA : How to Program - Deitel and Deitel - Internet and Web Programming with Java"/><category term="JColorChooser"/><category term="JDBC"/><category term="JEditorPane"/><category term="JInternalFrame"/><category term="JSP"/><category term="JSlider"/><category term="JSpinner"/><category term="JTable"/><category term="James D Foley-Van Dam A- Steven and Hughes"/><category term="Java Basic"/><category term="Kay Robbins"/><category term="Konigsberg Problem"/><category term="Kurose and Ross"/><category term="LCM"/><category term="Leland L. Beck"/><category term="Lexicographic Sorting"/><category term="Library management System"/><category term="Line Coding Schemes"/><category term="Line chart"/><category term="List (awt)"/><category term="Log4j"/><category term="Logging"/><category term="Logic Diagramming"/><category term="Loops"/><category term="MMD"/><category term="Mathematics"/><category term="Method Overloading"/><category term="Method Overriding"/><category term="Microprocessors and Microcontrollers"/><category term="Midpoint Ellipse Algorithm"/><category term="Midpoint Line Algorithm"/><category term="Mouse Event(awt)"/><category term="Natural Resources"/><category term="NeST"/><category term="Non-Preemptive"/><category term="Number of Digits"/><category term="Number of Pageviews"/><category term="OR Questions"/><category term="OS"/><category term="PLC"/><category term="Pattersen D.A. and Hennesy J.L."/><category term="Pearson Education"/><category term="Permutation"/><category term="Phonebook"/><category term="Picture"/><category term="Polygon"/><category term="Pop"/><category term="Positive numbers-Negativenumbers-Fractions"/><category term="Postfix Evaluation"/><category term="Postfix to Infix"/><category term="Preemptive"/><category term="PreparedStatement"/><category term="Priority Scheduling"/><category term="Programming Language Concepts"/><category term="Push"/><category term="R. Elmasri and S. B. Navathe: - Fundamentals of Database Systems - 5th Edition - Addison-Wesley"/><category term="R. Motwani and J.D. Ullman"/><category term="Readers-Writers"/><category term="Recursive Predictive Parser"/><category term="Roger S. Pressman"/><category term="Roundrobin"/><category term="S7 ppt"/><category term="SJN"/><category term="Scanner"/><category term="Scroll bar (awt)"/><category term="Searching Algorithm"/><category term="Sector"/><category term="Select Lines"/><category term="Session"/><category term="Shortest Job Next"/><category term="Silberschatz-H. F. Korth- S.Sudarshan"/><category term="Sinx"/><category term="Software Engineering – A practitioner’s Approach"/><category term="Steve Robbins"/><category term="Stevens W Richard"/><category term="String Search and Replacement"/><category term="Strong number"/><category term="Structure"/><category term="Student Record Management System"/><category term="System Software – An Introduction to Systems Programming"/><category term="Template"/><category term="Text Colour"/><category term="Text Editor"/><category term="Time of Last Visit"/><category term="UNIX Network Programming"/><category term="UNIX Systems Programming"/><category term="User Datagram Protocol"/><category term="Validation"/><category term="Vector"/><category term="Visible Surface Detection"/><category term="Vowels"/><category term="White Space"/><category term="Window To Viewport Transformation"/><category term="drawpoly()"/><category term="ex"/><category term="fillpoly()"/><category term="innerHTML"/><category term="ppt 5"/><category term="ppt_sem8"/><category term="s4"/><title type='text'>●.. My B.Tech ..● 2K8618.blogspot.com  - 2K8CSE</title><subtitle type='html'>Computer Science &amp;amp; Engineering Portal</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://2k8618.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default?max-results=3&amp;redirect=false'/><link rel='alternate' type='text/html' href='http://2k8618.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default?start-index=4&amp;max-results=3&amp;redirect=false'/><author><name>Nn</name><uri>http://www.blogger.com/profile/09802208823852709501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>346</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>3</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-544760739631615763.post-3672118846453556012</id><published>2014-10-09T01:13:00.001+05:30</published><updated>2015-12-05T15:43:50.283+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="D3 js"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Visualisation"/><category scheme="http://www.blogger.com/atom/ns#" term="Line chart"/><title type='text'>Simple Line Chart Using D3 js with Animation, Value points and Tooltip</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-family: inherit; font-size: x-large;&quot;&gt;A Simple Line Chart Using D3 js with Animation, Value points and Tooltip&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
Inspired from great visualizations of data using&amp;nbsp;&lt;b&gt;&lt;a href=&quot;http://d3js.org/&quot; target=&quot;_blank&quot;&gt;d3js.org&lt;/a&gt;, &lt;/b&gt;a simple line chart using d3js with animation, value points and tooltip.&lt;br /&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/d3js/3.4.12/d3.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;div id=&quot;tooltip&quot; style=&quot;background-color: #dddddd; display: none;border-radius: 5px; border: 1px solid #000; height: 20px; padding-left: 15px; padding-right: 15px; padding: 5px; position: absolute; width: 30px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;svg height=&quot;600&quot; id=&quot;my-line-chart&quot; width=&quot;600&quot;&gt;&lt;/svg&gt;

&lt;script&gt;
 drawLineChart();
 function drawLineChart(){

  var chartArea=d3.select(&#39;#my-line-chart&#39;);
  var lineData=[ { x: 0, y: 5},{ x: 20, y: 50 },{ x: 30, y: 45 },{ x: 40, y: 100 },{ x: 50, y: 65 },
    { x: 60, y: 75 },{ x: 70, y: 15 },{ x: 80, y: 85 },{ x: 90, y: 30 },{ x: 100, y: 0 }];

  //setting scale functions
  var xScale=d3.scale.linear().range([0,500]).domain(d3.extent(lineData, function(d){ return d.x;}));
  var yScale=d3.scale.linear().range([500,0]).domain(d3.extent(lineData, function(d){ return d.y;}));
  
  //setting axis functions
  xAxis = d3.svg.axis().scale(xScale).tickSize(2);
  yAxis = d3.svg.axis().scale(yScale).tickSize(2).ticks(20).orient(&quot;left&quot;);
  
  //drawing axes
  chartArea.append(&#39;g&#39;).attr(&#39;class&#39;,&#39;x axis&#39;).call(xAxis).attr(&#39;transform&#39;, &#39;translate(30,510)&#39;);
  chartArea.append(&#39;g&#39;).attr(&#39;class&#39;,&#39;y axis&#39;).call(yAxis).attr(&#39;transform&#39;, &#39;translate(30,10)&#39;);
  
  //line path generator function
  var linePathGenerator = d3.svg.line().x( function(d){
   return xScale(d.x);
  }).y(function(d){
   return yScale(d.y);
  });
  
  //drawing line 
  var linePath=chartArea.append(&#39;path&#39;).datum(lineData)
  .attr({
   &#39;d&#39; : linePathGenerator,
   &#39;fill&#39;: &#39;none&#39;,
   &#39;transform&#39;: &#39;translate(30,10)&#39;,
   &#39;stroke&#39;: &#39;rgb(9, 112, 184)&#39;,
   &#39;stroke-width&#39; : 3
  });
  
  // animation 
  var pathLength = linePath.node().getTotalLength();
  linePath.attr({
   &quot;stroke-dasharray&quot; : pathLength  + &quot; &quot; + pathLength,
   &quot;stroke-dashoffset&quot; : pathLength
  }).transition().duration(3000).ease(&quot;linear&quot;)
  .attr(&quot;stroke-dashoffset&quot;, 0);
   
   //points
  var circlePoints=chartArea.selectAll(&#39;circle&#39;)
  .data(lineData)
  .enter()
  .append(&#39;circle&#39;)
  .attr({cx :  function(d){
   return xScale(d.x)+30;
  }, cy : function (d){
   return yScale(d.y)+10;
  }, r :5,
  fill : &#39;silver&#39; 
  });
  
  // tooltip
  var div= d3.select(&#39;#tooltip&#39;);
  circlePoints.on(&quot;mouseover&quot;, function(d) {      
   div.transition()        
    .duration(200).style(&quot;display&quot;, &quot;block&quot;);    
            div.html(d.y) 
               .style(&quot;left&quot;, (d3.event.pageX) + &quot;px&quot;)     
               .style(&quot;top&quot;, (d3.event.pageY - 28) + &quot;px&quot;);    
        }).on(&quot;mouseout&quot;, function(d) {       
            div.transition()        
                .duration(500)      
.style(&quot;display&quot;, &quot;none&quot;);
        });
}
&lt;/script&gt;

&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;style&amp;gt;
svg{
 background-color : none;
}
.axis{
 stroke : #0000001;
 fill : silver;
}
#tooltip{
 position : absolute;
 border : 1px solid #000;
 background-color : #ddd;
 padding : 5px;
 padding-left: 15px;
 padding-right : 15px;
 border-radius : 5px;
}


&amp;lt;/style&amp;gt;
&amp;lt;script src=&quot;https://cdn.jsdelivr.net/d3js/3.4.12/d3.min.js&quot; type=&quot;text/javascript&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;svg id=&quot;my-line-chart&quot; width=&quot;600&quot; height=&quot;600&quot;&amp;gt;&amp;lt;/svg&amp;gt;
&amp;lt;div id=&quot;tooltip&quot;&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script&amp;gt;
 drawLineChart();
 function drawLineChart(){

  var chartArea=d3.select(&#39;#my-line-chart&#39;);
  var lineData=[ { x: 0, y: 5},{ x: 20, y: 50 },{ x: 30, y: 45 },{ x: 40, y: 100 },{ x: 50, y: 65 },
    { x: 60, y: 75 },{ x: 70, y: 15 },{ x: 80, y: 85 },{ x: 90, y: 30 },{ x: 100, y: 0 }];

  //setting scale functions
  var xScale=d3.scale.linear().range([0,500]).domain(d3.extent(lineData, function(d){ return d.x;}));
  var yScale=d3.scale.linear().range([500,0]).domain(d3.extent(lineData, function(d){ return d.y;}));
  
  //setting axis functions
  xAxis = d3.svg.axis().scale(xScale).tickSize(2);
  yAxis = d3.svg.axis().scale(yScale).tickSize(2).ticks(20).orient(&quot;left&quot;);
  
  //drawing axes
  chartArea.append(&#39;g&#39;).attr(&#39;class&#39;,&#39;x axis&#39;).call(xAxis).attr(&#39;transform&#39;, &#39;translate(30,510)&#39;);
  chartArea.append(&#39;g&#39;).attr(&#39;class&#39;,&#39;y axis&#39;).call(yAxis).attr(&#39;transform&#39;, &#39;translate(30,10)&#39;);
  
  //line path generator function
  var linePathGenerator = d3.svg.line().x( function(d){
   return xScale(d.x);
  }).y(function(d){
   return yScale(d.y);
  });
  
  //drawing line 
  var linePath=chartArea.append(&#39;path&#39;).datum(lineData)
  .attr({
   &#39;d&#39; : linePathGenerator,
   &#39;fill&#39;: &#39;none&#39;,
   &#39;transform&#39;: &#39;translate(30,10)&#39;,
   &#39;stroke&#39;: &#39;rgb(9, 112, 184)&#39;,
   &#39;stroke-width&#39; : 3
  });
  
  // animation 
  var pathLength = linePath.node().getTotalLength();
  linePath.attr({
   &quot;stroke-dasharray&quot; : pathLength  + &quot; &quot; + pathLength,
   &quot;stroke-dashoffset&quot; : pathLength
  }).transition().duration(3000).ease(&quot;linear&quot;)
  .attr(&quot;stroke-dashoffset&quot;, 0);
   
   //points
  var circlePoints=chartArea.selectAll(&#39;circle&#39;)
  .data(lineData)
  .enter()
  .append(&#39;circle&#39;)
  .attr({cx :  function(d){
   return xScale(d.x)+30;
  }, cy : function (d){
   return yScale(d.y)+10;
  }, r :8,
  fill : &#39;silver&#39; 
  });
  
  // tooltip
  var div= d3.select(&#39;#tooltip&#39;);
  circlePoints.on(&quot;mouseover&quot;, function(d) {      
   div.transition()        
    .duration(200)      
                .style(&quot;opacity&quot;, .9);      
            div.html(d.y)  
               .style(&quot;left&quot;, (d3.event.pageX) + &quot;px&quot;)     
               .style(&quot;top&quot;, (d3.event.pageY - 28) + &quot;px&quot;);    
        }).on(&quot;mouseout&quot;, function(d) {       
            div.transition()        
                .duration(500)      
                .style(&quot;opacity&quot;, 0);   
        });
}
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://2k8618.blogspot.com/feeds/3672118846453556012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://2k8618.blogspot.com/2014/10/simple-line-chart-using-d3-js-with.html#comment-form' title='130 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default/3672118846453556012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default/3672118846453556012'/><link rel='alternate' type='text/html' href='http://2k8618.blogspot.com/2014/10/simple-line-chart-using-d3-js-with.html' title='Simple Line Chart Using D3 js with Animation, Value points and Tooltip'/><author><name>Nn</name><uri>http://www.blogger.com/profile/09802208823852709501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>130</thr:total></entry><entry><id>tag:blogger.com,1999:blog-544760739631615763.post-3649237393290011042</id><published>2013-07-31T07:46:00.002+05:30</published><updated>2013-07-31T07:48:02.207+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache Tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="Log In Example"/><category scheme="http://www.blogger.com/atom/ns#" term="MySQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Struts"/><category scheme="http://www.blogger.com/atom/ns#" term="Struts 1.3"/><title type='text'>Struts Login Form Example Eclipse MySql Apache Tomcat</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif; font-size: x-large;&quot;&gt;Struts Login Example&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif; font-size: large;&quot;&gt;Struts 1.3 Java Eclipse MySql Apache Tomcat&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Project Screenshot:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1SbX15KyXy6YEkwax80y6rWAPb6QWfoV15Pro1TaY5WtzIwKmkEHG4X16c1Jm81BjcQXaQzmhBr6cmDTYJSp_qglIo3hgPm2nv-sHxmaiYpvlox3eh_Pz6TRDhuKXEnPWk5kXFiZ57vg/s1600/screenshot.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;126&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1SbX15KyXy6YEkwax80y6rWAPb6QWfoV15Pro1TaY5WtzIwKmkEHG4X16c1Jm81BjcQXaQzmhBr6cmDTYJSp_qglIo3hgPm2nv-sHxmaiYpvlox3eh_Pz6TRDhuKXEnPWk5kXFiZ57vg/s320/screenshot.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Project Explorer:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGUEKx4ij8R1wokJErMQJzRSA3dQPj0k8DOQ-X2-pqZ6PvyNvB7dbAL37iAzCBBxOSImVT9iKReyeA9vvATKm6wWFzMNtPoQfcn_uJbCLMVcDVwaBl5Hj39eYGxjHKq1lc84cozG3y9cY/s1600/project+explorer.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGUEKx4ij8R1wokJErMQJzRSA3dQPj0k8DOQ-X2-pqZ6PvyNvB7dbAL37iAzCBBxOSImVT9iKReyeA9vvATKm6wWFzMNtPoQfcn_uJbCLMVcDVwaBl5Hj39eYGxjHKq1lc84cozG3y9cY/s1600/project+explorer.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Source code:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;struts-config.xml&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;

&amp;lt;!DOCTYPE struts-config PUBLIC
          &quot;-//Apache Software Foundation//DTD Struts Configuration 1.3//EN&quot;
          &quot;http://struts.apache.org/dtds/struts-config_1_3.dtd&quot;&amp;gt;

&amp;lt;struts-config&amp;gt;

    &amp;lt;!-- Form Beans --&amp;gt;
    &amp;lt;form-beans&amp;gt;
        
        &amp;lt;form-bean name=&quot;loginForm&quot; type=&quot;com.loginexample.forms.LoginForm&quot;/&amp;gt;

    &amp;lt;/form-beans&amp;gt;

    &amp;lt;!-- Action Mappings --&amp;gt;
    &amp;lt;action-mappings&amp;gt;

     &amp;lt;action name=&quot;loginForm&quot; path=&quot;/Login&quot; type=&quot;com.loginexample.actions.LoginAction&quot; scope=&quot;request&quot; input=&quot;/Login.jsp&quot;&amp;gt;
         &amp;lt;forward name=&quot;failure&quot; path=&quot;/Failure.jsp&quot; redirect=&quot;true&quot;/&amp;gt;
         &amp;lt;forward name=&quot;success&quot; path=&quot;/Success.jsp&quot; redirect=&quot;true&quot;/&amp;gt;
     &amp;lt;/action&amp;gt;

    &amp;lt;/action-mappings&amp;gt;
    
    &amp;lt;!-- Message Source --&amp;gt;
     &amp;lt;message-resources parameter=&quot;com.loginexample.resources.Application&quot;/&amp;gt;

&amp;lt;/struts-config&amp;gt;
&lt;/pre&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;web.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;2.5&quot;&amp;gt;
  &amp;lt;display-name&amp;gt;StrutsLoginFormExample&amp;lt;/display-name&amp;gt;
  &amp;lt;servlet&amp;gt;
    &amp;lt;servlet-name&amp;gt;action&amp;lt;/servlet-name&amp;gt;
    &amp;lt;servlet-class&amp;gt;org.apache.struts.action.ActionServlet&amp;lt;/servlet-class&amp;gt;
    &amp;lt;init-param&amp;gt;
      &amp;lt;param-name&amp;gt;config&amp;lt;/param-name&amp;gt;
      &amp;lt;param-value&amp;gt;
          /WEB-INF/struts-config.xml
       &amp;lt;/param-value&amp;gt;
    &amp;lt;/init-param&amp;gt;
    &amp;lt;load-on-startup&amp;gt;2&amp;lt;/load-on-startup&amp;gt;
  &amp;lt;/servlet&amp;gt;
  &amp;lt;servlet-mapping&amp;gt;
    &amp;lt;servlet-name&amp;gt;action&amp;lt;/servlet-name&amp;gt;
    &amp;lt;url-pattern&amp;gt;*.do&amp;lt;/url-pattern&amp;gt;
  &amp;lt;/servlet-mapping&amp;gt;
  &amp;lt;welcome-file-list&amp;gt;
    &amp;lt;welcome-file&amp;gt;index.jsp&amp;lt;/welcome-file&amp;gt;
  &amp;lt;/welcome-file-list&amp;gt;
&amp;lt;/web-app&amp;gt;
&lt;/pre&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;Login.jsp&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&amp;gt;
&amp;lt;%@taglib prefix=&quot;html&quot; uri=&quot;http://struts.apache.org/tags-html&quot;%&amp;gt;
&amp;lt;%@taglib prefix=&quot;logic&quot; uri=&quot;http://struts.apache.org/tags-logic&quot;%&amp;gt;
&amp;lt;%@taglib prefix=&quot;bean&quot; uri=&quot;http://struts.apache.org/tags-bean&quot;%&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;&amp;lt;bean:message key=&quot;loginform.label.title&quot;/&amp;gt;&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;center&amp;gt;
&amp;lt;h1&amp;gt;&amp;lt;bean:message key=&quot;loginform.label.title&quot;/&amp;gt;&amp;lt;/h1&amp;gt;
&amp;lt;html:form action=&quot;/Login&quot; focus=&quot;username&quot;&amp;gt;
&amp;lt;table&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;
 &amp;lt;bean:message key=&quot;loginform.label.usernane&quot;/&amp;gt;
 &amp;lt;/td&amp;gt;
 &amp;lt;td&amp;gt;
   &amp;lt;html:text property=&quot;username&quot;/&amp;gt;
  &amp;lt;/td&amp;gt;
  &amp;lt;td&amp;gt;
  &amp;lt;logic:messagesPresent property=&quot;username&quot;&amp;gt;
   &amp;lt;html:messages id=&quot;error&quot; property=&quot;username&quot;&amp;gt;
    &amp;lt;font color=&quot;red&quot;&amp;gt;&amp;lt;bean:write name=&quot;error&quot;/&amp;gt;&amp;lt;/font&amp;gt;
   &amp;lt;/html:messages&amp;gt;
  &amp;lt;/logic:messagesPresent&amp;gt;
 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;
  &amp;lt;bean:message key=&quot;loginform.label.password&quot;/&amp;gt;
 &amp;lt;/td&amp;gt;
 &amp;lt;td&amp;gt;
  &amp;lt;html:password property=&quot;paswd&quot;/&amp;gt;
 &amp;lt;/td&amp;gt;
 &amp;lt;td&amp;gt; 
 &amp;lt;logic:messagesPresent property=&quot;paswd&quot;&amp;gt;
  &amp;lt;html:messages id=&quot;error&quot; property=&quot;paswd&quot;&amp;gt;
   &amp;lt;font color=&quot;red&quot;&amp;gt;&amp;lt;bean:write name=&quot;error&quot;/&amp;gt;&amp;lt;/font&amp;gt;
  &amp;lt;/html:messages&amp;gt;
 &amp;lt;/logic:messagesPresent&amp;gt;
 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
  &amp;lt;td align=&quot;left&quot;&amp;gt;
 &amp;lt;html:submit value=&quot;Login&quot;/&amp;gt;
 &amp;lt;html:reset value=&quot;Cancel&quot;/&amp;gt;
 &amp;lt;/td&amp;gt;
  &amp;lt;td&amp;gt;
 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;/html:form&amp;gt;
&amp;lt;/center&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;Success.jsp&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;Login Successful&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
 &amp;lt;h1&amp;gt;Login Successful&amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;Failure.jsp&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;Login Failure&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
 &amp;lt;h1 style=&quot;color: red;&quot;&amp;gt;Login Failure&amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;LoginForm.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {


 /**
  * nn
  */
 private static final long serialVersionUID = 1L;
 private String username = null;
 private String paswd = null;
 
 public String getUsername() {
  return username;
 }
 
 public void setUsername(String username) {
  this.username = username;
 }
 
 public String getpaswd() {
  return paswd;
 }
 
 public void setpaswd(String paswd) {
  this.paswd = paswd;
 }
 
 @Override
 public void reset(ActionMapping mapping, HttpServletRequest request) {
  this.paswd = null;
 }
 public ActionErrors validate(ActionMapping mapping,
   HttpServletRequest request) {
  ActionErrors errors = new ActionErrors();
  if(username==null || username.length()==0 || username.trim().equals(&quot;&quot;))
  {
   ActionMessage message = new ActionMessage(&quot;loginform.username.empty&quot;);
   errors.add(&quot;username&quot;, message);
  }
  else if(!username.matches(&quot;^[a-zA-Z0-9 ]+$&quot;))
  {
   errors.add(&quot;username&quot;, new ActionMessage(&quot;loginform.username.alphabets&quot;));
  }
  else if(username.length()&amp;lt;3)
  {
   errors.add(&quot;username&quot;, new ActionMessage(&quot;loginform.username.length&quot;));
   
  }
  if(paswd==null||paswd.length()==0||paswd.trim().equals(&quot;&quot;))
  {
   errors.add(&quot;paswd&quot;, new ActionMessage(&quot;loginform.paswd&quot;));
  }
  
 
 return errors;
 }
 

}

&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;LoginAction,java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.loginexample.forms.LoginForm;
import com.loginexample.services.LoginService;

public class LoginAction extends Action {
 @Override
 public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception {
  LoginForm loginForm = (LoginForm)form;
  LoginService loginService= new LoginService();
  
  try
  {
   loginService.checkLogin(loginForm);
   return mapping.findForward(&quot;success&quot;);
  }
  catch (Exception e)
  {
   return mapping.findForward(&quot;failure&quot;);
  }
 
 }

}

&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;LoginService.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.services;

import java.sql.SQLException;

import com.loginexample.dao.impl.LoginDaoImplementation;
import com.loginexample.exceptions.InvalidUserException;
import com.loginexample.forms.LoginForm;

public class LoginService {
 public boolean checkLogin(LoginForm loginForm) throws SQLException, InvalidUserException
 {
  LoginDaoImplementation loginDao= new LoginDaoImplementation();
  if(!loginDao.checkLogin(loginForm))
    throw new InvalidUserException(&quot;Incorrect Username/Password.&quot;);
  else
   return true;
 }

}

&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;LoginDao.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.dao;

import java.sql.SQLException;

import com.loginexample.forms.LoginForm;

public interface LoginDao 
{
public boolean checkLogin(LoginForm loginForm) throws SQLException;
}

&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;LoginDaoImplementation.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.dao.impl;

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

import com.loginexample.dao.LoginDao;
import com.loginexample.forms.LoginForm;
import com.loginexample.utilities.DBUtilities;

public class LoginDaoImplementation implements LoginDao
{
 public boolean checkLogin(LoginForm loginForm) throws SQLException
 {
  Connection con=null;
  boolean access=false;
  
  try
  {
   con=DBUtilities.getConnection();
   
   String query= &quot;select * from login where username=? and password=?&quot;;
   PreparedStatement stmt= con.prepareStatement(query);
   stmt.setString(1, loginForm.getUsername());
   stmt.setString(2, loginForm.getpaswd());
   ResultSet rs= stmt.executeQuery();
   
   if(rs.next())
   {
    access=true;
   }
  
   
  }
  finally
  {
   DBUtilities.closeConnection(con);
  }
  return access;
 }
}


&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;DBUtilities.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.utilities;

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

public class DBUtilities {
 
    public static Connection getConnection()
    {
     Connection con = null;
     
     try 
     {
    Class.forName(&quot;com.mysql.jdbc.Driver&quot;);
    con  =DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/nn&quot;,&quot;root&quot;,&quot;&quot;);
     } 
     catch (ClassNotFoundException e) 
     {
   // TODO Auto-generated catch block
      e.printStackTrace();
     } 
     catch (SQLException e) 
     {
   // TODO Auto-generated catch block
      e.printStackTrace();
     }
     
     return con; 
     
    }
 
     public static void closeConnection(Connection con){      
      if(con!=null){
       try{
       con.close();
       }catch(SQLException e){}
      }      
     }   
       public static void closePreparedStatement(PreparedStatement ps){      
      if(ps!=null){
       try{
       ps.close();
       }catch(SQLException e){}
      }
      
     }

}


&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;InvalidUserException.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.exceptions;

public class InvalidUserException extends Exception
{

 /**
  * 
  */
 private static final long serialVersionUID = 1L;

 public InvalidUserException(String arg0) 
 {
  super(arg0);
 }
 

 
}

&lt;/pre&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px;&quot;&gt;&lt;span style=&quot;color: #343333; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Application.properties&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;loginform.label.title=Login Form
loginform.label.usernane=Username : 
loginform.label.password=Password : 
loginform.username.empty=Please enter username
loginform.username.alphabets=Please enter alphabets only
loginform.username.length=Please enter username of length of at least 3 characters
loginform.paswd=Please enter password

&lt;/pre&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;background-color: white; color: #343333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px;&quot;&gt;&lt;br /&gt;Download: &lt;/b&gt;&lt;a href=&quot;http://www.4shared.com/zip/LkpocX5y/StrutsLoginFormExample.html&quot; target=&quot;_blank&quot;&gt;StrutsLoginFormExample&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://2k8618.blogspot.com/feeds/3649237393290011042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://2k8618.blogspot.com/2013/07/struts-login-form-example-eclipse-mysql.html#comment-form' title='29 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default/3649237393290011042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default/3649237393290011042'/><link rel='alternate' type='text/html' href='http://2k8618.blogspot.com/2013/07/struts-login-form-example-eclipse-mysql.html' title='Struts Login Form Example Eclipse MySql Apache Tomcat'/><author><name>Nn</name><uri>http://www.blogger.com/profile/09802208823852709501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1SbX15KyXy6YEkwax80y6rWAPb6QWfoV15Pro1TaY5WtzIwKmkEHG4X16c1Jm81BjcQXaQzmhBr6cmDTYJSp_qglIo3hgPm2nv-sHxmaiYpvlox3eh_Pz6TRDhuKXEnPWk5kXFiZ57vg/s72-c/screenshot.JPG" height="72" width="72"/><thr:total>29</thr:total></entry><entry><id>tag:blogger.com,1999:blog-544760739631615763.post-8845927405807550289</id><published>2013-07-20T14:08:00.001+05:30</published><updated>2013-07-23T20:17:18.432+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Apache Tomcat"/><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="MySQL"/><category scheme="http://www.blogger.com/atom/ns#" term="Struts"/><category scheme="http://www.blogger.com/atom/ns#" term="Struts 1.3"/><title type='text'>Registration Form - Struts 1.3  Example - Eclipse - MySQL - Apache Tomcat</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;h2&gt;
&lt;span style=&quot;font-family: Times, Times New Roman, serif; font-size: x-large;&quot;&gt;Simple Struts Example: Registration Form&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;h4&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; line-height: 20px;&quot;&gt;Struts 1.3 - Java - MySQL- Eclipse -&amp;nbsp;Apache Tomcat&lt;/span&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;Project Screenshots:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDZxGUHgoqBmSipo2blwGE7Lq9-gnGwPY8B63nSGvdBYq_yMV3tUJ73pSZogzicIBCggzgEeXd6J-5f7J_o_qlRU_H1IxSlNo5B-mwDxfB-w8R7uv7RRERUg4mxDvnFeluQgDkl1IKAVc/s1600/reg.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;182&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDZxGUHgoqBmSipo2blwGE7Lq9-gnGwPY8B63nSGvdBYq_yMV3tUJ73pSZogzicIBCggzgEeXd6J-5f7J_o_qlRU_H1IxSlNo5B-mwDxfB-w8R7uv7RRERUg4mxDvnFeluQgDkl1IKAVc/s320/reg.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;Project Explorer:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY0TCZdN6V3ThvRXLZV6oUWPzs6j1ZqKeL4-4jL9kioq-lHPZTzV-cwFQcF_EF5RWQI6_CYNCqbaAaXGO7kHrMLy4hmOThDCAfJmb4vwVUOMc2uVM1e7f1uFrUowzttZZP3Ndi2ZTz4_g/s1600/project+explorer.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhY0TCZdN6V3ThvRXLZV6oUWPzs6j1ZqKeL4-4jL9kioq-lHPZTzV-cwFQcF_EF5RWQI6_CYNCqbaAaXGO7kHrMLy4hmOThDCAfJmb4vwVUOMc2uVM1e7f1uFrUowzttZZP3Ndi2ZTz4_g/s320/project+explorer.JPG&quot; width=&quot;153&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;b&gt;Source code:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #343333; font-family: Verdana, sans-serif; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;b&gt;struts-config.xml
&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;

&amp;lt;!DOCTYPE struts-config PUBLIC
          &quot;-//Apache Software Foundation//DTD Struts Configuration 1.3//EN&quot;
          &quot;http://struts.apache.org/dtds/struts-config_1_3.dtd&quot;&amp;gt;

&amp;lt;struts-config&amp;gt;

    
    &amp;lt;form-beans&amp;gt;
        
  &amp;lt;form-bean name=&quot;registrationForm&quot; type=&quot;com.loginexample.forms.RegistrationForm&quot;/&amp;gt;

    &amp;lt;/form-beans&amp;gt;

    
    &amp;lt;action-mappings&amp;gt;

     &amp;lt;action name=&quot;registrationForm&quot; path=&quot;/register&quot; type=&quot;com.loginexample.actions.RegistrationAction&quot; scope=&quot;request&quot; input=&quot;/Register.jsp&quot;&amp;gt;
         &amp;lt;forward name=&quot;failure&quot; path=&quot;/Failure.jsp&quot; redirect=&quot;true&quot;/&amp;gt;
         &amp;lt;forward name=&quot;success&quot; path=&quot;/Success.jsp&quot; redirect=&quot;true&quot;/&amp;gt;
     &amp;lt;/action&amp;gt;

    &amp;lt;/action-mappings&amp;gt;
     

&amp;lt;/struts-config&amp;gt;
&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;web.xml&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;web-app xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:web=&quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot; id=&quot;WebApp_ID&quot; version=&quot;2.5&quot;&amp;gt;
  &amp;lt;display-name&amp;gt;StrutsLoginFormExample&amp;lt;/display-name&amp;gt;
  &amp;lt;!-- WWW.2K8618.BLOGSPOT.COM --&amp;gt;
  &amp;lt;servlet&amp;gt;
    &amp;lt;servlet-name&amp;gt;action&amp;lt;/servlet-name&amp;gt;
    &amp;lt;servlet-class&amp;gt;org.apache.struts.action.ActionServlet&amp;lt;/servlet-class&amp;gt;
    &amp;lt;init-param&amp;gt;
      &amp;lt;param-name&amp;gt;config&amp;lt;/param-name&amp;gt;
      &amp;lt;param-value&amp;gt;
          /WEB-INF/struts-config.xml
       &amp;lt;/param-value&amp;gt;
    &amp;lt;/init-param&amp;gt;
    &amp;lt;load-on-startup&amp;gt;2&amp;lt;/load-on-startup&amp;gt;
  &amp;lt;/servlet&amp;gt;
  &amp;lt;servlet-mapping&amp;gt;
    &amp;lt;servlet-name&amp;gt;action&amp;lt;/servlet-name&amp;gt;
    &amp;lt;url-pattern&amp;gt;*.do&amp;lt;/url-pattern&amp;gt;
  &amp;lt;/servlet-mapping&amp;gt;
  &amp;lt;welcome-file-list&amp;gt;
    &amp;lt;welcome-file&amp;gt;index.jsp&amp;lt;/welcome-file&amp;gt;
  &amp;lt;/welcome-file-list&amp;gt;
&amp;lt;/web-app&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-size: 12px; line-height: 20px; text-align: center;&quot;&gt;&lt;b&gt;Register.jsp&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;   pageEncoding=&quot;ISO-8859-1&quot;%&amp;gt;
&amp;lt;%@ taglib uri=&quot;http://struts.apache.org/tags-html&quot; prefix=&quot;html&quot;%&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;Registration Form&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;center&amp;gt;
&amp;lt;h1&amp;gt;Registration Form &amp;lt;/h1&amp;gt;
&amp;lt;html:form action=&quot;/register&quot; &amp;gt;
 Username : &amp;lt;html:text property=&quot;username&quot;/&amp;gt;&amp;lt;br/&amp;gt;
 &amp;lt;br/&amp;gt;
 Password : &amp;lt;html:password property=&quot;paswd&quot;/&amp;gt;&amp;lt;br/&amp;gt;
 &amp;lt;br/&amp;gt;
 &amp;lt;html:submit value=&quot;Register&quot; /&amp;gt;
&amp;lt;/html:form&amp;gt;
&amp;lt;/center&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/pre&gt;
&lt;b&gt;RegistrationForm.java&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.forms;

import org.apache.struts.action.ActionForm;


public class RegistrationForm extends ActionForm
{
  /**
  * 
  */
 private static final long serialVersionUID = 1L;
  private String username = null;
  private String paswd = null;
  
  public String getUsername() {
   return username;
  }
  
  public void setUsername(String username) {
   this.username = username;
  }
  
  public String getpaswd() {
   return paswd;
  }
  
  public void setpaswd(String paswd) {
   this.paswd = paswd;
  }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;RegistrationAction.java&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.loginexample.forms.RegistrationForm;
import com.loginexample.services.LoginService;

public class RegistrationAction extends Action {
 @Override
 public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception {
  RegistrationForm regForm=(RegistrationForm) form;
  LoginService loginService= new LoginService();
  
  try
  {
   if(loginService.addLogin(regForm))
    return mapping.findForward(&quot;success&quot;);
   else
    return mapping.findForward(&quot;failure&quot;);
  }
  catch (Exception e)
  {
   return mapping.findForward(&quot;failure&quot;);
  }
 
 }

}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;LoginService.java&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.services;

import java.sql.SQLException;

import com.loginexample.dao.impl.LoginDaoImplementation;
import com.loginexample.forms.RegistrationForm;

public class LoginService {
 LoginDaoImplementation loginDao= new LoginDaoImplementation();
 
 public boolean addLogin(RegistrationForm regForm) throws SQLException
 {
  if(loginDao.addLogin(regForm))
   return true;
  else
   return false;
 }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;LoginDao.java
&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.dao;

import java.sql.SQLException;

import com.loginexample.forms.RegistrationForm;

public interface LoginDao 
{
 public boolean addLogin(RegistrationForm regForm) throws SQLException;
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;LoginDaoImplementation.java&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.dao.impl;

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

import com.loginexample.dao.LoginDao;
import com.loginexample.forms.RegistrationForm;
import com.loginexample.utilities.DBUtilities;

public class LoginDaoImplementation implements LoginDao
{
 public boolean addLogin(RegistrationForm regForm) throws SQLException
 {
  Connection con=null;
  boolean access=false;
  
  try
  {
   con=DBUtilities.getConnection();
   
   String query= &quot;insert into login values (?,?)&quot;;
   PreparedStatement stmt= con.prepareStatement(query);
   stmt.setString(1, regForm.getUsername());
   stmt.setString(2, regForm.getpaswd());
   int result= stmt.executeUpdate();
   
   if(result&amp;gt;0)
   {
    access=true;
   }
  }
  finally
  {
   DBUtilities.closeConnection(con);
  }
  return access;
 }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;DBUtilities.java&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;package com.loginexample.utilities;

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

public class DBUtilities {
 
    public static Connection getConnection()
    {
     Connection con = null;
     
     try 
     {
    Class.forName(&quot;com.mysql.jdbc.Driver&quot;);
    con  =DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/nn&quot;,&quot;root&quot;,&quot;nn&quot;);
     } 
     catch (ClassNotFoundException e) 
     {
   // TODO Auto-generated catch block
      e.printStackTrace();
     } 
     catch (SQLException e) 
     {
   // TODO Auto-generated catch block
      e.printStackTrace();
     }
     
     return con; 
     
    }
 
     public static void closeConnection(Connection con){      
      if(con!=null){
       try{
       con.close();
       }catch(SQLException e){}
      }      
     }   
       public static void closePreparedStatement(PreparedStatement ps){      
      if(ps!=null){
       try{
       ps.close();
       }catch(SQLException e){}
      }
      
     }

}

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Success.jsp&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;Registration Successful&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;center&amp;gt;
 &amp;lt;h1&amp;gt;Registration Successful&amp;lt;/h1&amp;gt;
&amp;lt;/center&amp;gt; 
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Failure.jsp&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:jfx&quot;&gt;&amp;lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot;
    pageEncoding=&quot;ISO-8859-1&quot;%&amp;gt;
&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
&amp;lt;title&amp;gt;Registration Failure&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;center&amp;gt;
 &amp;lt;h1 style=&quot;color: red;&quot;&amp;gt;Registration Failed.&amp;lt;/h1&amp;gt;
&amp;lt;/center&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
MySql Database&lt;br /&gt;
&lt;pre style=&quot;background-color: #585454; color: white; width: 70%;&quot;&gt;mysql&amp;gt; desc login;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| username | varchar(20) | YES  |     | NULL    |       |
| password | varchar(25) | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
2 rows in set (0.06 sec)

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Download: &lt;a href=&quot;http://www.4shared.com/zip/gzN3sl08/StrutsExampleRegistration_1.html&quot; target=&quot;_blank&quot;&gt;StrutsExampleRegistration&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://2k8618.blogspot.com/feeds/8845927405807550289/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://2k8618.blogspot.com/2013/07/registration-form-struts-13-example.html#comment-form' title='17 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default/8845927405807550289'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/544760739631615763/posts/default/8845927405807550289'/><link rel='alternate' type='text/html' href='http://2k8618.blogspot.com/2013/07/registration-form-struts-13-example.html' title='Registration Form - Struts 1.3  Example - Eclipse - MySQL - Apache Tomcat'/><author><name>Nn</name><uri>http://www.blogger.com/profile/09802208823852709501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDZxGUHgoqBmSipo2blwGE7Lq9-gnGwPY8B63nSGvdBYq_yMV3tUJ73pSZogzicIBCggzgEeXd6J-5f7J_o_qlRU_H1IxSlNo5B-mwDxfB-w8R7uv7RRERUg4mxDvnFeluQgDkl1IKAVc/s72-c/reg.JPG" height="72" width="72"/><thr:total>17</thr:total></entry></feed>