how to create a dynamic website

how to create a dynamic website

View Answers

November 7, 2008 at 3:13 PM

Hi friend,

<html>
<title>employee form in servlets</title>
<head>

<script type="text/javascript">

function checkEmail(email) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
return (true)
}
alert("Invalid email address.Please Enter again.")
return (false);
}

function validateForm(theForm){



if(theForm.empname.value==""){

//Please enter username

alert("Please enter User Name.");

theForm.empname.focus();

return false;

}



if(theForm.lastname.value==""){

//Please enter lastname

alert("Please enter Last Name.");

theForm.lastname.focus();

return false;

}

if(theForm.email.value==""){
alert("Please enter email!");
theForm.email.focus();
return false;
}
if(!checkEmail(theForm.email.value)){
theForm.email.focus();
return false;
}

return true;
}
</script>
</head>

<body>
<center>
<table border="0" width="600px" bgcolor="lightblue" cellpadding="2" cellspacing="4">
<tr>
<td width="100%">
<form method="GET" action="InsertDataAction" onsubmit="return validateForm(this);">

<h2 align="center" align="top">Employee Registration Form</h2>
<table border="0" width="100%">
<tr>
<td width="50%"><b>Employee Name:</b></td>
<td width="50%"><input type="text" name="empname" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Middle Name:</b></td>
<td width="50%"><input type="text" name="midname" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Last Name:</b></td>
<td width="50%"><input type="text" name="lastname" size="20"/> </td>
</tr>
<tr>
<td width="50%"><b>Address:</b></td>
<td width="50%"><input type="text" name="address" size="50"/> </td>
</tr>

<td width="50%"><b>E-mail:</b></td>
<td width="50%"><input type="text" name="email" size="30"/> </td>
</tr>

</table><center><p>
<input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset">
</center>
</form>
</td>
</tr>
</table>
</center>
</body>

</html>

November 7, 2008 at 3:32 PM

This is Action code.

package javacode;

import java.io.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class InsertDataAction extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws
ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
System.out.println("Insert data Example!");
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String userName = "amar";
String password = "amar123";
Connection con = null;
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String empname=request.getParameter("empname");
String midname =request.getParameter("midname");
String lastname =request.getParameter("lastname");
String address=request.getParameter("address");
String email =request.getParameter("email");

int val = st.executeUpdate("insert into empDetail(empname,midname,lastname,address,email) values('"+empname+"','"+midname+"','"+lastname+"','"+address+"','"+email+"')");
con.close();
out.println("success data insert into database");
}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

}
}

---------------------

November 7, 2008 at 3:35 PM

web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>



<web-app xmlns="http://java.sun.com/xml/ns/javaee";

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";

version="2.5">



<description>

Servlet and JSP Examples.

</description>

<display-name>Servlet and JSP Examples</display-name>

<servlet>
<servlet-name>insertDataAction</servlet-name>
<servlet-class>javacode.InsertDataAction</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>insertDataAction</servlet-name>
<url-pattern>/jsp/InsertDataAction</url-pattern>
</servlet-mapping>

</web-app>

------------------------------

Visit for more information.

http://www.roseindia.net/servlets/


Thanks.

Amardeep









Related Tutorials/Questions & Answers:
how to create a dynamic website - Servlet Interview Questions
how to create a dynamic website  create a dynamic website of a topic of your choice. Web technologies to be used should include: HTML, JavaScript, Applets, Serverlets, and Database.  Hi friend, employee form
How to create dynamic array in C?
How to create dynamic array in C?  How to create dynamic array in c programming language?   Dynamic Array in C Tutorial
Advertisements
How to Create Dynamic URLs in PHP?
How to Create Dynamic URLs in PHP?  How to Create Dynamic URLs in PHP
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?  HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?
HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE?  HOW TO CREATE COMMENT IN WEBSITE AND CONNECT TO DATABASE
How to add or create instant messaging in website?
How to add or create instant messaging in website?  How to add or create instant messaging in website
How to add or create instant messaging in website?
How to add or create instant messaging in website?  How to add or create instant messaging in website
how we can create website through java
how we can create website through java  Dear actually i wanna ask query about creation of website through java then how we can create web site through java plz help me..........i have already a web site ....specially for premium
create dynamic array in javascript
create dynamic array in javascript  How to create dynamic array in javascript
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I have some problems creating a page to add items into a cart. The page loads dynamic products from a database, and i would like to know how to group this products
how to create a new table for the already existing user in the website
how to create a new table for the already existing user in the website  haiii....i want the code in jsp "how to create a new database for every user that has been already existing in the website?"....plzzzz help me
create dynamic image gallery jquery
create dynamic image gallery jquery  How to create a dynamic image gallery in Jquery
Create dynamic page through JSP
how to create dynamic page. This code shows one by one record of student from... Create dynamic page through JSP..., application fetch next record from database. Create a database :  Before
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I...: How to create seperate table for all users they sign up for my web app. i need... files but i done create and update for a single table. i dono how to automate
i want to create dynamic calendar in java
i want to create dynamic calendar in java  i want code and explanation
i want to create dynamic calendar in java
i want to create dynamic calendar in java  i want code and explanation
how to add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
How to Upload a Website?
to design their own website, to upload a website for the internet audience is a matter... a self designed website and upload it on the internet may sound simple but there are many aspects that you must know as for better performance of your website
Dynamic Website Designing
Dynamic Website Designing The Dynamic sites differ from the static in terms... and appears when it is asked to access. Dynamic website is quicker in uploading... of the pages. We at Roseindia Tech. have a vast experience of dynamic website designing
ModuleNotFoundError: No module named 'odoo10-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo10-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo10-addon-website-sale-suggest-create...;odoo10-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo10-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo10-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo10-addon-website-sale-suggest-create...;odoo10-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create...;odoo11-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create...;odoo11-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo11-addon-website-sale-suggest-create...;odoo11-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo12-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo12-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo12-addon-website-sale-suggest-create...;odoo12-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo13-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo13-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo13-addon-website-sale-suggest-create...;odoo13-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo13-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo13-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo13-addon-website-sale-suggest-create...;odoo13-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo8-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo8-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo8-addon-website-sale-suggest-create...;odoo8-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo9-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo9-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo9-addon-website-sale-suggest-create...;odoo9-addon-website-sale-suggest-create-account' error? Thanks   Hi
ModuleNotFoundError: No module named 'odoo9-addon-website-sale-suggest-create-account'
ModuleNotFoundError: No module named 'odoo9-addon-website-sale-suggest-create...: ModuleNotFoundError: No module named 'odoo9-addon-website-sale-suggest-create...;odoo9-addon-website-sale-suggest-create-account' error? Thanks   Hi
how to host a website
how to host a website  what are the steps to host a website?????plz reply iam in need of it... r else tell me the website address where i can get the idea
how to build a website
how to build a website  i hv developed i dynamic web project using eclipse,now i want to convert this project into an one touch executable software .is it possible to do the same.?if anyone knows it plz help me out
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project in Training and Placement.i have a created a company register part where i create a dynamic table for every company.but whenever i'm inserting values to the company
how to host a website using asp.net
how to host a website using asp.net  what are steps to host a website
How to include website in google search?
How to include website in google search?  Does anyone has idea about how to include a website into Google Search?   Visit the given Google website link on how to oiptimize or submit your website to Google. http
website
website  How to paste data directly on any website' text box
How to add dynamic table in java
How to add dynamic table in java  How to add dynamic table in java   import java.awt.*; import java.sql.*; import java.util.*; import javax.swing.*; import java.awt.event.*; import javax.swing.table.*; public class
How to add nofollow in website link?
How to add nofollow in website link?  Hi, I want to add nofollow in my outgoing links. What is the code? Thanks   Hi, Here is the code: <a rel="nofollow" href="http://">Click Here to visit</a>
how gave security of my pages in website????
how gave security of my pages in website????  how gave security of my pages in website
how to create array in r
how to create array in r  Hi, In R Programming how array is created? how to create array in r? Explain me the process of array creation using.... You can create an array with the help of array keyword. Following is an example
website
website  i have uploaded website .website is woking properly in chrome & firefox but not in IE
website
website  design and coding of first page of any forum website in jsp
How to convert http website into Https from java?
How to convert http website into Https from java?  could any one tell me how to convert http website into Https from java
How to embed an executable plugin in my website?
How to embed an executable plugin in my website?  I want to embed an executable plugin in my website that will return client's Mac address run time. I am working with jsp/servlet. Please Help
how to store dynamic array in hidden field in javascript?
how to store dynamic array in hidden field in javascript?  I have created array of textboxes dynamically in html using javascript. i just want... in how to store it in hidden field
HOW TO DO WEBSITE INTERFACE FOR JAVA MODULE
HOW TO DO WEBSITE INTERFACE FOR JAVA MODULE  Hi , Greetings. I... information etc. All these modules work fine in browser. I use JCreator. How to place these modules into website with selection button where when home button
how to store a dynamic values - JSP-Servlet
how to store a dynamic values  Dear sir, i have a ArrayList in that i have stored a values from a excel sheet specified column values and i have one string that is as follows Dear ~2 , Your cl is ~3 ,el is ~4
How to embed a Javascript in your wordpress website?
How to embed a Javascript in your wordpress website?  Hi, I own a wordpress website that offers a wide range of premium accounts of allmajor File..., Megaupload, etc. And now I want to insert a javascript into my wordpress website
how to done calculation for dynamic generated textboxes in jquery/javascript/ajax?
how to done calculation for dynamic generated textboxes in jquery/javascript/ajax?  how to done calculation for dynamic generated textboxes in jquery/javascript/ajax
How to create an input box?
How to create an input box?  How to create an input box

Ads