WTrecord
WTrecord
Result:
Result:
Result:
Result :
Thus login form validation using java script is implemented and executed successfully
Aim:
To design the scientific calculator using JavaScript
Algorithm:
1. Start the Process.
2. Include <HTML> tag to identify it as a HTML document.
3. Include a title for the document using <TITLE> Tag in head section
4. Specify the form by using the <FORM> tag and specify the name for the form.
5. Create the table by using the <TABLE> tag.
6. Specify the number of rows by using <TR> tag.
7. Specify the data for the table by using <TD> tag.
8. Specify the column heading by using <TH> tag.
9. Include the appropriate JavaScript definitions using the <SCRIPT> tag. Used to validate
the user input, perform the arithmetic calculations like +, -, /, *, sin, cos, tan, sqrt etc.
10. Close all the tags.
Coding:
<html>
<head><title>SCIENTIFIC CALCULATOR</title>
<SCRIPT LANGUAGE="JavaScript">
function addChar(input, character) {
if(input.value == null || input.value == "0")
input.value = character
else
input.value += character
}
function cos(form) {
form.display.value = Math.cos(form.display.value);
}
function sin(form) {
form.display.value = Math.sin(form.display.value);
}
function tan(form) {
form.display.value = Math.tan(form.display.value);
}
function sqrt(form) {
form.display.value = Math.sqrt(form.display.value);
}
function ln(form) {
form.display.value = Math.log(form.display.value);
}
function exp(form) {
form.display.value = Math.exp(form.display.value);
}
function deleteChar(input) {
input.value = input.value.substring(0, input.value.length - 1)
}
function changeSign(input) {
if(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}
function compute(form) {
form.display.value = eval(form.display.value)
}
function square(form) {
form.display.value = eval(form.display.value) * eval(form.display.value)
}
function checkNum(str) {
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i+1)
if (ch < "0" || ch > "9") {
if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "."
&& ch != "(" && ch!= ")") {
alert("invalid entry!")
return false
}
}
}
return true
}
</SCRIPT>
</head>
<body bgcolor="pink" text=red >
</body>
</html>
Output:
Result :
Thus scientific calculator using java script is implemented and executed successfully
Aim:
To design the Sorting Using JavaScript Array .
Algorithum:
1. Start the Process.
2. Include <HTML> tag to identify it as a HTML document.
3. Include the appropriate JavaScript definitions using the <SCRIPT> tag
4. Using prompt window get user input to sort the number.
5. Using array sort number in ascending sort.
6. Close all the tags.
Coding:
<html>
<head>
<title> Sort
</title>
<script language="Javascript">
var b,i,j,temp;
var a;
a=[];
document.write("Enter array");
for(i=0;i<5;i++)
{
b=prompt("enter array element=","0");
a[i]=b;
}
for(i=0;i<5;i++)
{
document.write("<br>"+a[i]);
}
document.write("<br>Sorted array is");
for(i=0;i<5;i++)
{for(j=0;j<5;j++)
{if(a[i]<a[j])
{temp=a[i];
a[i]=a[j];
a[j]=temp;
}}}
for(i=0;i<5;i++)
{document.write("<br>"+a[i]);
}</script>
</head>
</html>
Output
Result :
Result :
Thus Character and String Processing using java script is implemented and executed
successfully.
Aim:
To design a registration form using Java Script and HTML tags.
Algorithm:
1. Start the Process.
2. Include <HTML> tag to identify it as a HTML document.
3. Include a title for the document using <TITLE> Tag in head section
4. Include the JavaScript using the <SCRIPT> tag to print details registration in next page.
5. Specify the form by using the <FORM> tag and specify the name for the form.
6. Create the table by using the <TABLE> tag.
7. Specify the number of rows by using <TR> tag.
8. Specify the data for the table by using <TD> tag.
9. Specify the column heading by using <TH> tag.
10. Add the <OPTION> tag to select the state, caste.
11. Close the <FORM> tag.
12. Close all the tags.
Coding:
<html>
<head>
<title> Birth certificate Form </title>
<script language="javascript"type="text/javascript">
function namevalidate()
{document.writeln("</tr> Name:"+document.a.name.value+"<br>");
document.writeln("</tr> FatherName:"+document.a.f.value+"<br>");
document.writeln("</tr> MotherName:"+document.a.m.value+"<br>");
for(var i=0;i<=document.a.sex.length;i++)
{if(document.a.sex[i].checked)
{document.writeln("Sex :"+document.a.sex[i].value+"<br>");
break;
} }
document.writeln("</tr> Address:"+document.a.address.value+"<br>");
for(var i=0;i<=document.a.religion.length;i++)
{if(document.a.religion[i].checked)
{ document.writeln("Religion
:"+document.a.religion[i].value+"<br>");
break;
}}document.writeln("</tr> Birth Place:"+document.a.birth.value+"<br>");
document.writeln("</tr> Birth Date:"+document.a.place.value+"<br>");
document.writeln("</tr> Cast:"+document.a.cast.value+"<br>");
document.writeln("</tr><h3> you have successfully registered for birth certificate details
</h2>");
}</script>
</head>
<body bgcolor="pink" Birth Certificate>
<form name="a">
<table>
<tr >
<td><p> <B> Name: <B></td>
<td> <input type="text" name="name"></td>
</tr>
<tr>
<td>
<p> Father Name:</td><td> <input type="text" name="f"></td>
</tr>
<td><p> Mother Name: </td><td><input type="text" name="m"></td>
</tr>
<tr>
<td><p> Gender: <td><input type="radio" name="sex" value="Male">Male <input
type="radio" name="sex" value="Female">Female<br> </td>
</p></tr><tr>
<td> <p> Resediential Address: <td><textarea roes="4" cols="25"
name="address"></textarea></td></p>
</td></tr><td><p> Religion: </td><td>
<input type="radio" name="religion" value="Hindu">Hindu
<input type="radio" name="religion" value="Christian">Christian
<input type="radio" name="religion" value="Muslim">Muslim
<input type="radio" name="religion" value="Others">Others</td>
</tr><tr><td><p> Birth Date:<td> <input type ="number" name="birth"></td></p>
</td></tr><tr><td><p> Birth Place:<td>
<select name="place">
<option> Puducherry </option>
<option> Tamilnadu</option></select> </td>
</tr>
<tr><td><p> Cast: <td><select name="cast">
<option> MBC </option>
<option> OBC</option>
<option> SC </option>
</select></td>
</tr></p></table><p><input name="button2" type="button" value="Submit" onclick="
namevalidate()">
<input name="button" type="button" value="Reset" >
</form></body></html>
OUTPUT:
Result:
Thus registration form is designed using java script &HTML tag and the output is verified.
Aim:
To design an HTML document to implement the built in function using vb script.
Algorithm:
1. Start the Process.
2. Include <HTML> tag to identify it as a HTML document.
3. Include a title for the document using <TITLE> Tag in head section
4. Specify the form by using the <FORM> tag and specify the name for the form.
5. Add the <INPUT> tag to retrieve data from the user.
6. Include the <SCRIPT> tag to include the script language as VbScript.
7. Get the user input in an inputbox and perform a string operation like lowercase,
uppercase, length, reverse using a build in function. Display the output.
8. Display the today date and current time using the build in data/time function.
9. Get the user input in an inputbox and perform a mathematical function like log, sin, cos,
tan using build in function. Display the appropriate output.
10. Close all the tags.
Coding:
<Html>
<head>
<title>Built-in Functions in VBScript</title>
<Script type="Text/vbscript">
sub operation(a)
if a=1 then
msgbox("LowerCase of Given String is "&LCase(st.str.value))
elseif a=2 then
msgbox("UpperCase of Given String is "&UCase(st.str.value))
elseif a=3 then
msgbox("Length of Given String is "&Len(st.str.value))
elseif a=4 then
msgbox("Reverse of Given String is "&StrReverse(st.str.value))
elseif a=5 then
msgbox(Now)
elseif a=6 then
msgbox(Date)
elseif a=7 then
msgbox("The Log value of the given Number is"&Log(st.num.value))
elseif a=8 then
msgbox("The Sin value of the given Number is"&Sin(st.num.value))
elseif a=9 then
msgbox("The Cos value of the given Number is"&Cos(st.num.value))
elseif a=10 then
msgbox("The Tan value of the given Number is"&Tan(st.num.value))
End if
end sub
</Script>
</head>
<body bgcolor="cyan">
<form name="st">
<h1 align="center">Built-in Functions in VBScript</h1>
<h2>String Functions</h2>
<b>Enter a String:</b>
<input type="text" id="str"><br>
<br><input type=button value="Lower" onclick="operation(1)">
<input type=button value="Higher" onclick="operation(2)">
<input type=button value="Length" onclick="operation(3)">
<input type=button value="Reverse" onclick="operation(4)">
<br/><br/>
<h2>Date/Time Functions</h2>
<input type=button value="Date" onclick="operation(5)">
<input type=button value="Now" onclick="operation(6)">
<h2>Math Functions</h2>
<b>Enter a Number:</b>
<input type="text" id="num"><br>
<br><input type=button value="Log" onclick="operation(7)">
<input type=button value="Sin" onclick="operation(8)">
<input type=button value="Cos" onclick="operation(9)">
<input type=button value="Tan" onclick="operation(10)">
</form>
</body>
</Html>
Output:
Result :
Thus built in function using java script is implemented and executed successfully
Aim
To develop functional and procedural methods using VB Script in designing a web page.
Algorithm
1. Start the Process.
2. Include <HTML> tag to identify it as a HTML document.
3. Include a title for the document using <TITLE> Tag in head section.
4. Include the appropriate VBScript definitions using the <SCRIPT> tag. Create procedure
and function to get input from user.
5. Include <BODY> tag to enclose all the tags.
6. Enter the user name then click ok to print name in user page.
7. Close all the tags.
8. Run the code in internet explorer.
Source Code:
<html><head>
<script language="vbscript">
sub inputext
Dim a,b,dis
a="Hello Welcome. Please enter your name:"
b="just for your name"
dis=InputBox(a,b)
document.write("your name is :" &dis)
End sub
</script></head>
<body onload=inputext>
<form></form></body></html>
FUNCTIONS:
<html><head>
<script language="vbscript">
public function inputext
Dim a,b,dis
a="Hello Welcome. Please enter your name:"
b="just for your name"
dis=InputBox(a,b)
document.write("your name is :" &dis)
End function
</script></head>
<body onload=inputext>
<form></form>
</body></html>
Output
RESULT:
Thus a web page is developed using Functions and procedures in VB Script and the
output is verified.
AIM
To study the configuration of
A typical company that buys IIS can create pages for Web sites using Microsoft's Front
Page product (with its WYSIWYG user interface). Web developers can use Microsoft's Active
Server Page (ASP) technology, which means that applications - including ActiveX controls - can
be imbedded in Web pages that modify the content sent back to users. Developers can also write
programs that filter requests and get the correct Web pages for different users by using
Microsoft's Internet Server Application Program Interface (ISAPI) interface. ASPs and ISAPI
programs run more efficiently than common gateway interface (CGI) and server-side include
(SSI) programs, two current technologies. (However, there are comparable interfaces on other
platforms.) Microsoft includes special capabilities for server administrators designed to appeal to
Internet service providers
This section describes how to configure IIS for ColdFusion MX in Windows, and how to
verify your configuration. You configure IIS using the Web Server Configuration Tool in either
GUI or command-line mode. This describes how to use GUI mode. To use the command line,
open the batch files located in cf_root\bin\connectors.
1. Start the Web Server Configuration Tool by selecting Start > Programs > Macromedia
ColdFusion MX > Web Server Configuration Tool from the Start menu.
2. Click Add.
3. In the Server drop-down list box, select the host name and the server or cluster name that
you want to configure. In the ColdFusion MX server configuration, the server name is
always default. Clustering support is only available on the JRun J2EE configuration.
Note: The server or cluster does not have to reside on the web server computer.
4. In the Web Server Properties area, select IIS and specify the website. For IIS, you
typically specify All.
5. Select Configure web server for ColdFusion MX applications.
Caution: Omitting the previous step causes your web server to serve ColdFusion MX
source code.
Click OK.
6. Copy the CFIDE and cfdocs directories from cf_root\wwwroot to your web server root
directory. In addition, copy your application's CFM pages from cf_root\wwwroot to your
web server root directory
1. For each of your IIS websites, verify that application mappings for .cfm, .cfml, .cfc, .jsp,
and .jws were added, as follows:
a. In IIS, right-click an IIS website and select Properties.
b. In the Properties dialog box, on the Home Directory tab, click Configuration.
c. In the Application Configuration dialog box, click the App Mappings tab.
You should see mappings for .cfm, .cfml, .cfc, .jsp, and .jws in the Extension
column.
2. Verify that each of your IIS websites has a virtual directory called JRunScripts.
The following figure shows a sample JRunScripts virtual directory:
3. Verify that the JRunScripts directory in each of your IIS websites points to the correct
location, as follows:
a. Right-click the JRunScripts directory and select Properties.
b. In the Properties dialog box, on the Virtual Directories tab, verify that the Local
Path text box contains the following path: path/wsconfig/number (typically 1)
Most people will just want to download the,set and, and they are done. Make sure JDK 1.5 or 1.6
is installed and your PATH is set so that both "java -version" and "javac -help" give a result.
Your first step is to download and install Java. Tomcat 6.0 requires JDK 1.5 Standard Edition
(Java 5) or JDK 1.6 Standard Edition (Java 6). See the following sites for download and
installation information.
Once you've installed Java, confirm that everything including your PATH is configured properly
by opening a DOS window and typing "java -version" and "javac -help". You should see a
real result both times, not an error message about an unknown command. Or, if you use an IDE,
compile and run a simple program to confirm that the IDE knows where you installed Java.
For example, if you have JDK 1.5_08, you could set your PATH by putting the following line in
your C:\autoexec.bat file.
Configure Tomcat
Configuring Tomcat involves four main steps and five optional steps:
Details of each step are given below. If Tomcat is already running, restart it after performing
these steps.
Go to and download and unpack the zip file for the current release build of Tomcat 6. You
specify the top-level directory (e.g., C:\) and the zip file has embedded subdirectories (e.g.,
apache-tomcat-6.0.10). Thus, C:\apache-tomcat-6.0.10 is a common resultant installation
directory. Note: from this point forward, I'll refer to that location as install_dir. For Windows,
there is also a .exe installer; I prefer the .zip file, but see for notes on the differences between the
two.Alternatively, you can use my.This version already has the port changed to 80, servlet
reloading enabled, and the invoker servlet turned on. It also comes with a sample development
directory, autoexec.bat file, startup/shutdown shortcuts, and shortcuts for deploying applications.
Next, you must set the JAVA_HOME environment variable to tell Tomcat where to find Java.
Failing to properly set this variable prevents Tomcat from compiling JSP pages. This variable
should list the base JDK installation directory, not the bin subdirectory. For example, on almost
any version of Windows, if you use JDK 1.5_08, you might put the following line in your
C:\autoexec.bat file.
Assuming you have no other server already running on port 80, you'll find it convenient to
configure Tomcat to run on the default HTTP port (80) instead of the out-of-the-box port of
8080. Making this change lets you use URLs of the form http://localhost/blah instead of
http://localhost:8080/blah. Note that you need admin privileges to make this change on
Unix/Linux. Also note that some versions of Windows XP automatically start IIS on port 80. So,
if you use XP and want to use port 80 for Tomcat, you may need to disable IIS (see the
Administrative Tools section of the Control Panel).
To change the port, edit install_dir/conf/server.xml and change the port attribute of the
Connector element from 8080 to 80, yielding a result similar to that below.
Use my preconfigured Jakarta Tomcat version. Apache Tomcat 6.0.10 with all
server.xml, context.xml, and web.xml changes, plus the sample HTML, JSP, and Java
files.
Download my modified server.xml for Tomcat 6.0. From Apache Tomcat 6.0.10, but
should work on most versions of Tomcat 6.0. Right-click or shift-click on the link to
download the file.
4. Turn on Servlet Reloading
The next step is to tell Tomcat to check the modification dates of the class files of requested
servlets, and reload ones that have changed since they were loaded into the server's memory.
This slightly degrades performance in deployment situations, so is turned off by default.
However, if you fail to turn it on for your development server, you'll have to restart the server
every time you recompile a servlet that has already been loaded into the server's memory. Since
this tutorial discusses the use of Tomcat for development, this change is strongly recommended.
<Context>
to
<Context reloadable="true" privileged="true">
Note that the privileged entry is really to support the invoker servlet (see
the following section), so you can omit that entry if you do not use the
invoker.
Use my preconfigured Tomcat version. Tomcat 6.0.10 with all server.xml, context.xml,
and web.xml changes, plus the sample HTML, JSP, and Java files.
Download my modified context.xml for Tomcat 6.0. From Tomcat 6.0.10, but should
work on most versions of Tomcat 6.0. Right-click or shift-click on the link to download
the file.
The invoker servlet lets you run servlets without first making changes to your Web application's
deployment descriptor (i.e., the WEB-INF/web.xml file). Instead, you just drop your servlet into
WEB-INF/classes and use the URL http://host/servlet/ServletName (or
http://host/webAppName/servlet/ServletName once you start using your. The invoker servlet is
extremely convenient when you are learning and even when you are testing things doing your
initial development. You almost certainly want to enable it when learning, but you should disable
it again before deploying any real applications.To enable the invoker servlet, uncomment the
following servlet and servlet-mapping elements in install_dir/conf/web.xml. Do not confuse
this Apache Tomcat-specific web.xml file with the standard one that goes in the WEB-INF
directory of each Web applicationlass>
</servlet>
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
In Tomcat 6 (but not Tomcat 5.5), you also need the privileged="true" entry
in the Context element of context.xml. See the previous section for an
example.
Use my preconfigured Tomcat version. Tomcat 6.0 with all server.xml, context.xml, and
web.xml changes, plus the sample HTML, JSP, and Java files.
Download my modified web.xml for Tomcat 6.0. From Tomcat 6.0.10, but should work
on most versions of Tomcat 6.0. Right-click or shift-click on the link to download the
file.
In previous Tomcat versions, if you entered a URL ending in a slash (/) and there was no
welcome-file in the directory (or servlet-mapping that matched the URL), Tomcat displayed a
directory listing. In Tomcat 6, the default was changed from true to false for these directory
listings. Many developers find it convenient to turn directory listings back on. To make this
change, edit install_dir/conf/web.xml and change the init-param value of listings for the default
servlet, as below. Do not confuse this Apache Tomcat-specific web.xml file with the standard
one that goes in the WEB-INF directory of each Web application.t>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
You can also:
Use my preconfigured Tomcat version. Tomcat 6.0 with all server.xml, context.xml, and
web.xml changes, plus the sample HTML, JSP, and Java files.
Download my modified web.xml for Tomcat 6.0. From Tomcat 6.0.10, but should work
on most versions of Tomcat 6.0. Right-click or shift-click on the link to download the
file.
Please see the page to get a version of Jakarta Tomcat 6.0 with all configuration settings already
made. Just unzip the file, set your JAVA_HOME and CLASSPATH variables, and you are read to go.
If you are using Microsoft Windows, you can download a .exe installer instead of the .zip file
discussed in this tutorial. In my opinion, it is not worth the bother to do so, but some people like
it. If you use it, note these differences:
It will prompt you for the desired port. It will ask you what port it should run on, and
make the changes in server.xml for you. You will still need to manually edit context.xml
and web.xml, however.
It will set JAVA_HOME for you. The installer hunts for your Java installation and tries to set
JAVA_HOME appropriately. This is a convenience, albeit a minor one.
It will setup Start Menu entries. In particular, instead of using startup.bat and
shutdown.bat, you can go to the Start Menu, select Apache Tomcat 6.0, select Monitor
Tomcat, and select Start or Stop, as shown below. I prefer startup.bat and shutdown.bat
so that I can put shortcuts in my development directory (easier to invoke) and/or the
desktop (where I can associate keyboard shortcuts).
RESULT:
Thus the configuration of web server such as Internet Information Server(IIS) and
Apache Tomcat server have been studied.
Aim:
Create a webpage with ActiveX controls using OBJECT and PARAM tags.
Algorithm:
1. In HTML OBJECT and PARAM tags are used to insert ActiveX controls in Web page.
2. The OBJECT WIDTH specifies the width of a box enclosing the visible area of the
object. Use width instead of accessing the Width property.
3. The HEIGHT specifies the height of a box enclosing the visible area of the object. Use
height instead of accessing the Height property.
4. The TYPE specifies the Internet Media Type of the data specified by the DATA attribute.
Since this information can be accessed before the data is retrieved, it is possible to skip
over unsupported media types
5. The DATA indicates that the value is to be passed directly to the object as a string.
6. The CLASSID specifies a URL used to locate the object, or it specifies a class identifier
for the object. For ActiveX controls, CLASSID is used to specify the class identifier. The
class identifier is a unique alphanumeric code assigned to each ActiveX control and is
stored in the system Registry of the client computer
7. The PARAM tag to assign a value to a named property within the control. need to use
only the NAME and VALUE attributes.
8. The NAME specifies the property name.
9. The VALUE specifies the value for the named property.
10. The <embed> tag defines a container for an external application or interactive content (a
plug-in).
11. Save the HTML file and open in browser such Internet Explorer ,Mozilla Firefox etc..
Code:
<!DOCTYPE html>
<html>
<body>
<center> <b> <h2> ActiveX Controls in web documents</h2></b></center>
<object width="100%" height="100%"
type="video/x-ms-asf" url="10a.wmv" data="10a.wmv"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
<param name="url" value="10a.wmv">
<embed type="application/x-mplayer2" src="10a.wmv" width="100%" height="100%"
autostart="true" showcontrols="true"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"></embed>
</object></body></html>
Output:
Result:
Algorithm:
Code:
Book.html
<html>
<body>
<h2><u><center>Book Advisor Input</center></u></h2>
<form method="POST" action="BookSelect.do">
<select name="taste" size=1">
<option value="DBMS">DBMS</option>
<option value="Software Engineering"> Software Engineering</option>
<option value="Web Technology">Web Technology</option>
<option value="Wireless Communication">Wireless Communication</option>
</select>
<br/><br/>
<input type="Submit"/>
</form>
</body>
</html>
BookExpert.java
package com.example.model;
import java.util.*;
public class BookExpert {
public List<String> getTypes(String taste) {
List<String> result = new ArrayList<String>();
if (taste.equals("DBMS")) {
result.add("Database System Concepts by Abraham Silberschatz");
result.add("Modern Database Management by Addison-Wesley");
} else if (taste.equals("Software Engineering")) {
result.add("Software Engineering by Ian Sommerville");
result.add(" Software Engineering by Roger S. Pressman");
} else if (taste.equals("Web Technology")) {
result.add("Internet and World Wide Web How to Program by Deitel and Deitel,
Goldberg,");
result.add("Web Technology by Rajkamal");
result.add("Active X from the Ground Up by John Paul Mueller");
result.add("Understanding Web Services: XML, WSDL, SOAP, and UDDI by Eric
Newcome");
} else if (taste.equals("Wireless Communication")) {
result.add("Wireless Communications and Networks by William Stallings");
} else {
result.add(" Wireless Communications by Theodore S. Rappaport");
}
return (result);
}
}
BookSelect.java
package com.example.web;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.example.model.BookExpert;
book.jsp
<html>
<body>
<h2>Book Advisor Output</h2>
<c:forEach var="type" items="${types}">
<c:out value="${type}"/>
<br / >
</c:forEach>
</body>
</html>
web.xml
Result:
Thus successfully Book advisor Application implemented using MVC architecture and output is
verified.
Aim:
Create a JSP program to display the session id as well as the count which shows how
many times the page is accessed during the current session.
Algorithm:
1. The session object is an instance of Http Session.It used to track information about a
particular client. Each client has one global session object.
2. When user send the fist request to the JSP engine it will issue a session id to track the
information for the transaction. The JSP engine exposes the HttpSession object to the JSP
through the session object. The current session information collected following some of
methods available through session object
3. Use getCreationTime() method to return the time when the session was created and it is
measured in milliseconds .
4. Use getLastAccessedTime() method to returns the last time the client sent a request
associated with the session, as the number of milliseconds.
5. Use getAttribute(String name) method to return the object bound with the specified
name in the session, or null if no object is bound under the name
6. Use setAttribute(String name, Object value) method to binds an object to this session,
using the name specified.
7. Save code as session.jsp and run code, at first run Number of visits of page is 0 and it is
incremented at second run.
Code:
Session.jsp
<%@ page import="java.io.*,java.util.*" %>
<%
// Get session creation time.
Date createTime = new Date(session.getCreationTime());
// Get last access time of this web page.
Date lastAccessTime = new Date(session.getLastAccessedTime());
String title = "Welcome Back to my website";
Integer visitCount = new Integer(0);
String visitCountKey = new String("visitCount");
String userIDKey = new String("userID");
String userID = new String("ABCD");
// Check if this is new comer on your web page.
if (session.isNew()){
title = "Welcome to my website";
session.setAttribute(userIDKey, userID);
session.setAttribute(visitCountKey, visitCount);
} visitCount = (Integer)session.getAttribute(visitCountKey);
visitCount = visitCount + 1;
userID = (String)session.getAttribute(userIDKey);
session.setAttribute(visitCountKey, visitCount);
%>
Output
Result:
Thus program is implemented and it displays the session id and shows how many times
the page is accessed during the current session.
Aim:
Create a JSP program to display university results of students according to their register
No. and department.
Algorithm:
1. Create a result.jsp page which display university result page where student provide
register number and department information to know their results.
2. Create a table stud1.mdb to store students result information using msacess.
3. Create search.jsp to create database access connection.
4. After creating database connection search.jsp is linked with result.jsp.
5. Save search.jsp and result.jsp.
6. Run result.jsp.
Code:
Result.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Search result</title>
</head>
<body BGCOLOR="PINK">
<form name="form" method="post" action="ser.jsp" onsubmit="javascript:return validate();">
<H2><center> UNIVERSITY RESULTS </center></h2>
<center>
<table>
<tr>
<td>Register no:</td>
<td><input type="text" name="tr1" size="10" /></td></tr>
<TR>
<td>Course Category:</td>
<td><select name="tr1">
<option value="-1">-Select Category-</option>
<option value="CSE">B.TECH(CSE)</option>
<option value="ece">B.TECH(ECE)</option>
<option value="it">B.TECH(IT)</option>
<option value="mech">B.TECH(MECH)</option>
</select></td>
<td><input type="submit" value="RESULT" /></td>
</tr>
</table>
</center>
</form>
</body>
</html>
Search.jsp
<%@page import="java.sql.Connection"%>
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"
errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head><body>
<%String tr1 =request.getParameter("tr1");
String tr2 =request.getParameter("tr2");
try {
Connection connection = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connection = DriverManager.getConnection("jdbc:odbc:ni1");
Statement statement = connection.createStatement();
statement = connection.createStatement();
String QueryString = "select * from stud1 where register="+tr1+" and "+tr2+" " ;
ResultSet rs = statement.executeQuery(QueryString);
int count=0;
out.print("<CENTER>");
out.print("<H2>RESULT</H2>");
out.println("<TABLE border=1 cellpadding=15 style=background-color:PINK> <TR>
<TH>register</TH> <TH>name</TH> <TH>course</TH><TH>SE</TH>
<TH>DBMS</TH><TH>WT</TH></tr>");
while(rs.next())
{ out.println("<tr><td>" + rs.getInt(1) + "</td> <td>" + rs.getString(2) +
"</td><td>" + rs.getString(3) + "</td> <td>" + rs.getString(4) + "</td> <td>" + rs.getString(5) +
"</td><td>" + rs.getString(6) + "</td></tr>")count++;
} out.println("</table>");
out.print("<CENTER>");
{//out.println("Unable to connect to database.");
}} catch (Exception ex)
{out.println(ex);
}%></body></html>
Output:
Result:
Thus database connection created and student result also displayed successfully.
a)Reading Text File
Aim:
Create JSP program to manipulate file related task such as reading text file, checking file type .
Algorithm:
1. Create a text file name jsp.txt and put in same folder where fileRead.jsp jsp file is exists.
2. The getServletContext().getRealPath("/") method is used to get the absolute path of
jsp.txt jsp file.
3. The FileInputStream class is used to read bytes from file jsp.txt
4. The BufferedInputStream class buffering to input streams. Buffering used read a larger
block at a time.
5. The readLine() method is used to read the data line by line.
6. To check file exists , directory, or file using method f.exists(),f.isDirectory(), and
f.isFile()
7. The close() method is used to close file.
Code:
Reading text file in JSP
fileRead.jsp
<%@ page language="java" import="java.io.*" errorPage="" %>
<html>
<head>
<title>File Handling in JSP</title>
</head>
<body>
<h2><u><center>Reading text file in JSP </center></u></h2>
<%
String fileName=getServletContext().getRealPath("jsp.txt");
File f=new File(fileName);
InputStream in = new FileInputStream(f);
BufferedInputStream bin = new BufferedInputStream(in);
DataInputStream din = new DataInputStream(bin);
while(din.available()>0)
{
out.println(din.readLine());
out.print("<br>");
}
in.close();
bin.close();
din.close();
%></body></html>
INPUT - Jsp.txt
Output:
(b) Checking file type for existing, file or as directory
fileType.jsp
Output:
Result:
Thus JSP program to manipulate file as reading text file, checking file type is
implemented and executed successfully.
Aim:
create Ajax program using JSP to display name with hello message.
Algorithm:
1. Ajax is the method of using Javascript, DHTML
2. The XMLHttpRequest object Right-click on WebContent and click New=>JSP file and
create hello.html
3. Right-click on WebContent and click New=>File file and create hello1.jsp
4. Create an XML HttpRequest object to perform a GET or POST and return a result
without reloading the HTML page.
5. Create the function to be executed when the server response is ready
6. Send the request off to a file on the server
7. Notice that a parameter (q) is added to the URL (with the content of the input field)
8. Save hello.html and hello1.jsp.
9. Run hello.html. and Enter your name and click Go button Then it displays name with
hello message
Code:
Ajax.html
<html>
<head>
<title>Simple Ajax Example</title>
<script language="Javascript">
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
function getquerystring() {
var form = document.forms['f1'];
var word = form.word.value;
qstr = 'w=' + escape(word); // NOTE: no '?' before querystring
return qstr;
}
function updatepage(str){
document.getElementById("result").innerHTML = str;
}
</script>
</head>
<body bgcolor="pink">
<center> <h2> Ajax Programming </h2></center>
<form name="f1">
<center>
<p>Enter your name: <input name="word" type="text">
<input value="Go" type="button" onclick='JavaScript:xmlhttpPost("hello1.jsp")'></p></center>
<div id="result"></div>
</form>
</body>
</html>
Hello1.jsp
<%@ page language="java" contentType="application/x-www-form-urlencoded; charset=ISO-
8859-1"
pageEncoding="ISO-8859-1"%>
<%
String w = request.getParameter("w");
String msg = "Hello "+w;
%>
<%=msg%>
Output:
Result:
1. Creating New Project Goto File->New Project ( One window will open)
2. In Project Window , Select Web -> Web Application and Select Next
3. Enter the Name of the Project [Eg. MyServlet] , Select Next and Select finish
4. Create HTML file and Right click on the Web Pages Folder
5. Select New -> HTML option from the pop up window.
6. Type the name of html page as REGISTER.HTML. Finish the wizard.
7. Now Create new table name as LoginDetail with field need for contact form
8. Creating Servlet Right click on the Source Package Folder
9. Select New -> Servlet option from the pop up window.
10. Type the name of servlet as RegisterServlet.java and Finish the wizard.
11. Run the project. As URL => http://localhost:8084/MyServlet/select.html
12. Now Enter the details and and Submit it. Message box will come that you successfully
insert data in database .
Code:
REGISTER.HTML
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<CENTER> <h2> <b> Registration form for student </b> </h2></center>
<body bgcolor="lavender">
RegisterServlet.java
import java.io.IOException;
import java.io.PrintWriter;
import java.io.*;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Administrator
*/
@WebServlet(name = "registerServlet", urlPatterns = {"/registerServlet"})
public class registerServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:nit");
PreparedStatement stmt=con.prepareStatement("insert into LoginDetail
values(?,?,?,?,?,?,?,?,?,?,?)");
stmt.setString(1, name);
stmt.setString(2,dob );
stmt.setString(3, address);
stmt.setString(4,age );
stmt.setString(5,fathername );
stmt.setString(6, mothername);
stmt.setString(7, fatheroccupation);
stmt.setString(8, motheroccupation);
stmt.setString(9, school);
stmt.setString(10,tenth );
stmt.setString(11,tw );
int i=stmt.executeUpdate();
out.println("<h1><center>You are successfully Registered!</center</h1>");
con.close();
}
catch(Exception e)
{
out.println("<b>Registration failed</b>");
out.println("<b>Error:</b>" +e);
}
}
}
Output
Result
Thus student registration form implemented and executed successfully using javaservlet.
Aim:
Create a PHP program to register basic contact information.
Algorithm:
1. Install Wamp Server On PC. .
2. Now Start the Wamp Server and do right click and click on phpmyadmin .
3. PhphMyadmin page will open and clikck on New database and create new database with
name stud1
4. Now Create new table name as info with field need for contact form
5. Now Create Web page to get contact information
6. Create Php File Which Handle that request and save this file as insert1.php.
7. Put this both file in single Folder and Put this folder in Wamp installation directory,
inside WWW folder defalut path is C:\wamp\www\
8. Now again do right click and click on local host . Main Page of wampserver will open.
9. Now Contact1.html page will open.
10. Now Enter the details and and Submit it. Message box will come that you successfully
insert data in database
Code:
Contact1.html
<html>
<head>
</head>
<body bgcolor="Bisque">
<CENTER><h2>CONTACT FORM </h2></CENTER>
<CENTER>
<form action="insert1.php" method="post"><pre>
<B>
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Email id: <input type="text" name="email"><br>
TelePhone No:<input type="text" name="tele"><br>
Address: <input type="text" name="addr"></pre>
<input type="Submit">
</B>
</CENTER>
</form>
</body>
</html>
Result:
Thus contact form is implemented and executed using php
AIM: Create login page validation in asp
Algorithm:
1. Start the Process.
2. Include <HTML> tag to identify it as a HTML document.
3. Include a title for the document using <TITLE> Tag in head section
4. Add the <INPUT> tag to retrieve data from the user.
5. Include the appropriate ASP script definitions using the <% ....% > tag. Used to validate
the login form.
6. Close all the tags.
Source Code:
<%
'Green colorset
'BackgroundColor="#C9DDB3"
'BorderColor="#006600"
'Blue colorset
BackgroundColor="#AFD1F8"
BorderColor="#000080"
'Purple colorset
'BackgroundColor="#FDC8F2"
'BorderColor="#800080"
Content = ""'Clear the Content string
QStr = Request.QueryString("login") 'Save the login querystring to QStr
if ucase(left(QStr,6))="CREATE" then
Title = "Register"
else
Title = "Login"
end if
'The code below saves the contents the table must have in the variable Content
'The content depends on what's in the QueryString
if QStr="passfailed" then
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><P>Wrong password</P><A href=Javascript:history.go(-1)>Back</A></td></tr>"
elseif QStr="createpassfailed" then
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><P>Wrong password</P><A href=Javascript:history.go(-
1)>Back</A><BR><BR><A HREF=login.asp>Cancel registration</A></td></tr>"
elseif QStr="namefailed" the Content = Content & "<tr><td valign=top bordercolor="&
BackgroundColor &" align=center><P>Invalid username</P><A
HREF=login.asp?login=createnew>Click here to create an acount</A><BR><BR><A
HREF=Javascript:history.go(-1)>Back</A></td></tr>"
elseif QStr="createnamefailed" then
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><P>Invalid username</P><A HREF=Javascript:history.go(-
1)>Back</A><BR><BR><A HREF=login.asp>Cancel registration</A></td></tr>"
elseif QStr="creatednew" then
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><P>Your account has been created</P><A
HREF=login.asp>Login</A></td></tr>"
elseif QStr="createnew" then
Content = Content & "<form name=frmCreate method=POST
action=create.asp>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><br>Username: <input type=text name=txtUsername></td></tr>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center>Password: <input type=password name=txtPassword></td></tr>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><br>Full name: <input type=text name=txtFullname></td></tr>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><input type=submit name=cmdSubmit value=Register></td></tr>"
Content = Content & "</form>"
else
Content = Content & "<form name=frmMain method=POST action=verify.asp>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><br>Username: <input type=text name=txtUsername></td></tr>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center>Password: <input type=password name=txtPassword></td></tr>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><input type=submit name=cmdSubmit value=Login></td></tr>"
Content = Content & "<tr><td valign=top bordercolor="& BackgroundColor &"
align=center><input type=submit name=cmdSubmit value=Register></td></tr>"
Content = Content & "</form>"
end if%><!-- Build the page with the table -->
<head> <title>ASP Login</title>
</head><body link="<% Response.Write(BorderColor) %>" vlink="<%
Response.Write(BorderColor) %>" alink="<% Response.Write(BorderColor) %>" text="<%
Response.Write(BorderColor) %>"><br><div align="center">
<table border="2" cellspacing="5" bgcolor="<% Response.Write(BackgroundColor) %>"
bordercolor="<% Response.Write(BorderColor) %>"width="250px">
<% Response.Write("<tr><td valign=top align=center><b>" & Title &
"</b></td></tr>")
Response.Write(Content) ' Paste the contents in the table
%>
</table></div></body>
OUTPUT: http://localhost/Login_and_54210292002/login.asp
Result:
Thus login page validation is created and executed in asp
Problem Description:
The development of pharmacy helps the users to purchase different types of medicines
and also to view the medicine through online itself.
The website consists of details such as
1. Home
2. Login
3. Registration
4. Available medicine
5. Help
Project explanation:
The online Pharmacy is business-to-consumer electronic commerce is the most visible
business use of the World Wide Web. The primary goal of an e-commerce site is to sell
medicines and services online. This project deals with developing an e-commerce website for
Online Pharmacy Sale. It provides the user with different types of medicines available for
purchase. In order to facilitate online purchase a medicines is provided to the user. The system is
implemented using a 3-tier approach, with a backend database, a middle tier of a jsp and
javaservlet, and a web browser as the front end client.
Software Requirements
The Pharmacy application is implemented using the Net Beans IDE 7.1.0 tool, dynamic
web page are created using programming JSP and to store and retrieve data its connected with
MicrosoftAcess2003.
Modules Description
A small description of various modules used in this project is as follows,
Login Form:
The login form is the first module which helps the user in getting access to the system
functions.
Registration form:
The next form is the registration form. Here the user has to enter his or her details and
this helps in maintaining history of that particular person.
Available medicine
This page help user to check whether medicine available in pharmacy.
Database:
The database serves as a storage house in storing the medical name and availability and
other aspects related to the project.
Implementation
Source Code:
Main.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<link href="style.css" rel="stylesheet" type="text/css"> </link>
</head>
<body>
<div id="container">
<div id="header"> <img src="images/ilogo.jpg" alt="" id="logo">
<h1 id="logo-text">Pharmacy</h1>
</div>
<div id="nav">
<ul>
<li><a href="index.jsp">Home</a></li>
<li><a href="login.jsp">Log In </a></li>
<li><a href="reg.jsp">Registeration </a></li>
<li><a href="avi.jsp">Available medicine</a></li>
<li><a href="1help.html">Help</a></li>
</ul>
</div>
<div id="site-content">
<div id="col-left">
<h1 class="h-text-1">WELCOME</h1><p class="text-1"><strong> Pharmecy will show the
detail of medican which are availble</p>
<ul class="list-1">
<li>A malaria is treated by giving chloroquine, pirmaquire and paracetamal tablets.</li>
<li>Antihistamines - stop runny noses and sneezing.</li>
<li>Pain relievers - ease fever, headaches, and minor aches and pains.</li>
</ul>
<p class="border-1"> </p>
<h2 class="h-text-2">About us</h2>
<p class="text-1">Pharmacists and chemists play a key role in providing quality healthcare to
patients. Working in the community, primary care and hospitals, pharmacists use their clinical
expertise together with their practical knowledge to ensure the safe supply and use of medicines
by patients and members of the public
</p>
<p class="text-1">Pharmacists offer advice on common problems such as coughs, colds, aches
and pains, as well as healthy eating and stopping smoking. </p>
</div>
<div id="col-right">
<div style="padding: 30px 10px 10px;">
<h2 class="h-text-2">Latest News</h2>
<h3 class="h-text-3">Available Medican</h3>
<p class="text-2"><b>DEXTROMETHORPHAN<b>
Dextromethorphan is an over-the-counter cough suppressant that works by affecting the
portion of the human brain associated with coughing. It is found in most cold remedies and
cough medicines, and is sold as a liquid or capsule.
</p>
</div>
<div> </div>
<div style="padding: 5px 10px;">
<h2 class="h-text-2">Contact </h2>
</div>
<div
style="padding: 5px 10px 15px; background: rgb(216, 214, 215) none repeat scroll 0%; -moz-
background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy:
initial;">
<p class="text-2"> Pharmecy East Coast rode Puducherry<br>
<br>
E-mail: [email protected]<br>
<br>
Website: www.Pharmecy.com<br>
<br>
Phone: 9847854612<br>
</p>
</div>
</div>
</div>
</body>
</html>
Login.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
alert("Enter Username!");
return false;
}
if(password==""){
alert("Enter Password!");
return false;
}
return true;
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="fuchia">
<center>
<h3> Enter username and Password</h3>
<form name="form" method="post" action="loginvalid" onsubmit="javascript:return
validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</center>
</body>
</html>
Loginvalid.java:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
import javax.servlet.RequestDispatcher;
/**
*
* @author INDRAJITH
*/
@WebServlet(name = "loginvalid", urlPatterns = {"/loginvalid"})
public class loginvalid extends HttpServlet
{
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
String userName = request.getParameter("user");
String password = request.getParameter("pass");
//out.println("user name:" +userName);
//out.println("password:" +password);
if(login(userName, password)){
out.println(" Login is Successful ................");
//RequestDispatcher rd = request.getRequestDispatcher("Anotherservlet");
//rd.forward(request, response);
//cmd box
}
else {
out.println("Login Failed. Please Login Again..................");
//RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
// rd.forward(request, response);
}
}
boolean login(String userName, String password) {
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:pharm");
System.out.println("got connection");
Statement s = con.createStatement();
String sql = "SELECT * FROM login" +
" WHERE Username='" + userName + "'" +
" AND Password='" + password + "'";
ResultSet rs = s.executeQuery(sql);
if (rs.next())
{
rs.close();
s.close();
con.close();
return true;
}
rs.close();
s.close();
con.close();
}
catch (ClassNotFoundException e)
{
System.out.println(e.toString());
}
catch (SQLException e)
{
System.out.println(e.toString());
}
catch (Exception e)
{
System.out.println(e.toString());
}
return false;
}
}
Reg.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="burlywood">
<center>
<ul>
<li><a href="pur.jsp"><h4>Purchase the medicine</h4></a></li>
<li><a href="mail.html"><h4>View the details of medicine</h4> </a></li>
</ul> </center>
</body>
</html>
Pur.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="gainboro">
<center>
<h4> Enter Your Details </h4>
<form method="get" action="registerservelet ">
<tr><label><p>Name
<input type="text" name="Name" id="Name" /></p>
</label></tr>
<tr><label><p>Password
<input type="text" name="Password" id="Password" /></p>
</label></tr>
<tr><label><p>Address
<textarea name="Address" id="Address" cols="45" rows="5"></textarea></p>
</label></tr>
</tr><label><p>Contact
<input type="text" name="Contact" id="Contact" /></p>
</label>
</tr>
<label>
<input type="submit" value="Submit" />
</label><br>
</form>
<center>
</body>
</html>
Registerationservelet.java:
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.sql.*;
/**
*
* @author INDRAJITH
*/
@WebServlet(name = "registerservelet", urlPatterns = {"/registerservelet"})
public class registerservelet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException
{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String Name=request.getParameter("Name");
String Password=request.getParameter("Password" );
String Address=request.getParameter("Address");
String Contact=request.getParameter("Contact");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:pharm");
PreparedStatement stmt=con.prepareStatement("insert into Purchase values(?,?,?,?)");
stmt.setString(1, Name);
stmt.setString(2, Password);
stmt.setString(3, Address);
stmt.setString(4, Contact);
int i=stmt.executeUpdate();
out.println("You are Successfully Registered");
con.close();
}
catch(Exception e)
{
out.print("Registeration Failed");
out.println("Error:" +e);
}
}
}
View.html:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="hotpink">
<center>
<h3> Available Medicine Details </h3>
<h4> <b>Click the Button to view the Medicine Details </b></h4>
<form name="f" method="post" action="a.jsp">
<input type="submit" value="View">
</form>
</center>
</body>
</html>
a.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="lightpink">
<%@page language="java" %>
<%@page import="java.sql.*;" %>
<%
Statement s=null;
Connection cn=null;
ResultSet rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
cn=DriverManager.getConnection("jdbc:odbc:pharm");
s=cn.createStatement();
String str="select * from medicine";
rs=s.executeQuery(str);
while(rs.next())
{
out.println("Name of medicine: " +rs.getString(1)+"<br>");
out.println("Available Quantity: " +rs.getInt(2)+"<br>");
out.println("Manufacture Date: " +rs.getString(3)+"<br>");
out.println("Expire Date: " +rs.getString(4)+"<br>");
out.println("<hr>");
}
s.close();
cn.close();
%>
</body>
</html>
Avi.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<script>
function validate()
{
var Name=document.form.user.value;
if(Name=="")
{
alert("Enter the name");
return false;
}
return true;
}</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="peachpuff">
<center>
<form name="form" method="post" action="searchvalid" onsubmit="javascript:return
validate();">
<tr> <h2>Search for medicine </h2> </tr>
<td> <p><B> Enter the medicine Name:</b></p></td>
<td> <input type="text" name="Name"></td>
<input type="submit" value="Submit">
</form>
</center>
</body>
</html>
Searchvalid.java:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
/**
*
* @author INDRAJITH
*/
@WebServlet(name = "searchvalid", urlPatterns = {"/searchvalid"})
public class searchvalid extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
Card.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body bgcolor="lightblue">
<center>
<h3>Enter the details</h3>
<form id="form1" name="form1" method="get" action=" createcard">
<table>
<tr><td>Customer Name</td><td><input type="text" name="textfield" /></td></tr>
<tr><td>Address </td><td><input type="text" name="textfield2" /></td></tr>
<tr><td>City</td><td><input type="text" name="textfield3" /></td></tr>
<tr><td>State</td><td><input type="text" name="textfield4" /></td></tr>
<tr><td>Pin code</td><td><input type="text" name="textfield5" /></td></tr>
<tr><td>Phone no</td><td><input type="text" name="textfield6" /></td></tr>
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String CustomerName=request.getParameter("textfield");
String Address=request.getParameter("textfield2" );
String City=request.getParameter("textfield3");
String state=request.getParameter("textfield4");
String zipcode=request.getParameter("textfield5");
String phoneno=request.getParameter("textfield6" );
String Email=request.getParameter("textfield7");
String Cardtype=request.getParameter("select");
String Creditcardnumber=request.getParameter("textfield8");
String ExpireDate=request.getParameter("textfield9");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:pharm");
PreparedStatement stmt=con.prepareStatement("insert into card
values(?,?,?,?,?,?,?,?,?,?)");
stmt.setString(1, CustomerName);
stmt.setString(2, Address);
stmt.setString(3, City);
stmt.setString(4, state);
stmt.setString(5, zipcode);
stmt.setString(6, phoneno);
stmt.setString(7, Email);
stmt.setString(8, Cardtype);
stmt.setString(9, Creditcardnumber);
stmt.setString(10, ExpireDate);
int i=stmt.executeUpdate();
out.println("You are Successfully Registered");
con.close();
}
catch(Exception e)
{
out.print("Registeration Failed");
out.println("Error:" +e);
}
}
Help.html:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="palegreen">
<center><b>COUGH MEDICINES</b><p></p>
<b>Guaifenesin </b>
<p>Guaifenesin thins phlegm or mucus in people's lungs to help suppress or reduce
coughing.
It is found in both prescription and over-the-counter strengths.
Guaifenesin may cause abdominal pain, a rash, diarrhea, hives, nausea, headaches, dizziness
or vomiting.</p>
<b>Narcotics</b>
<p>Codeine is a prescription-only remedy for coughs.
It is an antitussive and acts on the brain's cough center, just as dextromethorphan does.
Codeine is a narcotic and may make your body dependent on it with prolonged use.</p>
<b><i>Carbetapentane</i></b>
<p>Carbetapentane is a non-narcotic cough suppressant.
Brand names include Rentamine 12, Tustan 12S, Tannihist 12RF, Ricotuss H and others.
Side effects may include confusion, seizures, constipation, insomnia, hallucinations, difficulty
breathing, dizziness and headaches.</p>
<b><i>Caramiphen</i></b>
<p>Caramiphen is a cough suppressant marketed as Tusso-Gest, Ordrine AT, Tuss Vernade and
Rescaps-D.
It is prescribed as capsules or tablets.
Caramiphen may produce such side effects as high blood pressure, nausea, insomnia, headaches,
a rash, chest pains, dizziness or drowsiness.</p>
</center>
</body>
</html>
Output:
Home page
Login Page:
Registration page
Help Page
Search for medicine
Shipping:
Result: Thus e commerce application for online pharmacy is created and executed.
Aim:
The aim of project is create a web service for project and consume by client .
Procedure:
package org.me.calculator;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
@WebService(serviceName = "CalculatorWS")
public class CalculatorWS {
/**
* Web service operation
*/
@WebMethod(operationName = "add")
public int add(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
//TODO write your implementation code here:
int k = i + j;
return k;
}
/**
* Web service operation
*/
@WebMethod(operationName = "sub")
public int sub(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
//TODO write your implementation code here:
int k = i - j;
return k;
}
/**
* Web service operation
*/
@WebMethod(operationName = "mul")
public int mul(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
//TODO write your implementation code here:
int k = i * j;
return k;
}
/
Web service operation
*/
@WebMethod(operationName = "Div")
public int Div(@WebParam(name = "i") int i, @WebParam(name = "j") int j) {
//TODO write your implementation code here:
int k = i / j;
return k;
}}
14.Now deploy and test the web service
15.Right-click the project and choose Deploy. The IDE starts the application server, builds the
application, and deploys the application to the server.
16.The IDE opens the tester page browser, if you deployed a web application to GlassFish.
17. http://localhost:8080/CalculatorWSApplication/CalculatorWS?Tester
Calculator operation:
Click add button
In this section, create a new web application and then consume the web service in the default JSP
page that the Web Application wizard creates.
19. Choose File > New Project (Ctrl-Shift-N). Select Web Application from the Web category.
Name the project CalculatorWSJSPClient. Click Finish.
20. Right-click the CalculatorWSJSPClient node and choose New > Web Service Client.
21. In Project, click Browse. Browse to the web service that you want to consume. When you
have selected the web service, click OK.
22. Leave the other settings at default (in 6.0.x, do not set a package name) and click Finish.
23. In the Web Service References node, expand the node that represents the web service. The
add, sub ,mul, div operations, which you will invoke from the client, is now exposed.
24. Drag the add operation to the client's index.jsp page, and drop it below the H1 tags. The code
for invoking the service's operation is now generated in the index.jsp page, as you can see
here:
Consume.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<center> <h1>Consuming the Calculator Web Service</h1></center>