Home Answers Viewqa Servlet-Interview-Questions how to create a dynamic website

 
 


langat
how to create a dynamic website
3 Answer(s)      4 years and 7 months ago
Posted in : Servlet Interview Questions

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 Pages:
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
create dynamic array in javascript
create dynamic array in javascript  How to create dynamic array in javascript
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
How to Create Dynamic URLs in PHP?
How to Create Dynamic URLs in PHP?  How to Create Dynamic URLs in PHP
create dynamic image gallery jquery
create dynamic image gallery jquery  How to create a dynamic image gallery in Jquery
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
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
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
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
website
website  How to paste data directly on any website' text box
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
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
To Develope an Website
To Develope an Website   Hi there, I am fresher,very new to CVS, and I want to create a website in Eclipse IDE, But I don't know how to create, please help me. What I did is I had created two XML files, web.xml
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
Object Adapter based on Dynamic Proxy,java,Dynamic Object Adapter using Dynamic Proxies,newsletter,tutorial
override adaptee behaviour). We then create a dynamic proxy of the target... work with JDK 1.3. Here is how I would use the dynamic object adapter..., specifically on how to use dynamic proxies in Java to autogenerate code
Make A website
Make A website  How expensive(hire someone) or hard would it be to create a website like this? I want to build a website where people can be users of the website with a small profile. Their is a point system (kinda like money
dynamic web pages in html
dynamic web pages in html  How to create Dynamic web pages in HTML
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
need dynamic image example
need dynamic image example  struts 2 img example for a dynamic image.. one that the user of the website uploads. To be more clear on what I am doing... this with the image. I need to see an example of how to do this for an image. I am
Website deployment on LAN
Website deployment on LAN  I have created a dynamic website in netbeans. Now i have to host the website on LAN so that by typing the URL... as to how i should go about it. I also have a database in Access 2007 at the backend
What is Static Website
without having much experience. The static website is ideal for demonstrating how... websites: Simple to create and host Cheaper in the comparison of dynamic...What is Static Website The static website is simple website design which
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
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 add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
Dynamic HREF link - Date Calendar
Dynamic HREF link  Hi, I want to know how to create a page with links to download the files present in one folder and if the no of files present in the folder changes the link for downloading changes automatically. For eg
how to maintain cookies throughout the website - JSP-Servlet
how to maintain cookies throughout the website  Hi to All, We are developing a website containing 10 web pages. whenever user logged in the site... but not working properly.My requirement is how to get the cookie in all pages. Please
Bulk insert and dynamic schema loading
on query. So how to load schema and create table dynamically? Which the best way...Bulk insert and dynamic schema loading  Hi All, I am new to H2 database and java. I have started working on these from past 1 month. I needs some
Dependant & dynamic drop down list
Dependant & dynamic drop down list  I don't know this should be in this or AJAX forum. I have one dynamic drop down list from data base (working... on the values selected by user in first drop down list. How to achieve this ?   
website - WebSevices
website  hi .how to update website
PHP MySQL Introduction
and MySQL together to store information on the web and create dynamic website... of both PHP and MySQL are used to develop or create dynamic and interactive website.  MySQL is supported, distributed and developed by MySQL AB. 
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
Creating Dynamic Tree component in RCFaces
that how you can create a dynamic tree component with the use of RCFaces core tag v... Creating Dynamic Tree component in RCFaces.... To create this tree we have used the RCFaces core tag v:tree. It has some
Website Designing Services
server. PHP – A scripting language used to create dynamic Web pages... website design, dynamic website design, database website design, flash website... following web designing services: Static Website Designing Dynamic Website
How to promote your writing through your website
How to promote your writing through your website  ... is an easy way to promote your book, through your own website. The catch remains how will you present your book and also how easy is it to access your website
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
ASP.net website
ASP.net website  Sir i want to how to lonch our website in internet pleas help me i have created a website in asp.net it is running in localhost but i want ren it in internet server
Dynamic form
Dynamic form  I need to make a dynamic form using jsp for example, i...; For the above code, we have created two database tables: CREATE TABLE `country..., PRIMARY KEY (`countryid`)); CREATE TABLE `state
dynamic form
dynamic form  I need to make a dynamic form using php, for example, i... need to create following database tables. CREATE TABLE `country` ( `id... '', PRIMARY KEY (`id`) ) ; CREATE TABLE `state` ( `id` tinyint(4) NOT NULL auto
Website deployment
Website deployment  Hi, I have created a website using servlet and jsp. I'm through with it now i want to deploy my website locally..., till now i was viewing the website by pressing f6 it is working fine. I also
Website deployment
Website deployment  Hi, I have created a website using servlet and jsp. I'm through with it now i want to deploy my website locally..., till now i was viewing the website by pressing f6 it is working fine. I also
create
create  how to create an excel file using java
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
Dynamic method dispatch
Dynamic method dispatch Dynamic dispatch is a process of selecting, which... display() ,class B extends A and override method display, we generally create... class method and child class method as well. Example :  How to implement
dynamic image change javascript
dynamic image change javascript  How to display images in JavaScript dynamically
Dependant & dynamic drop down list - Follow up
Dependant & dynamic drop down list - Follow up  Thanks for your... jsp for extract. How to achieve this ?   1)country.jsp: <%@page...: CREATE TABLE `country` ( `countryid

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.