EX NO: 1 IMAGE MAPPING USING HTML PROGRAM: INDIA.html <html> <head> <title>india map</title> <body bgcolor="black" align="center"> <img src="indiamap.jpg" alt="india map" usemap="#india"> <map name="india"> <area shape="rect" coords="543,1519,631,1664" alt="tamilnadu" href="tamilnadu.html"/> <area shape="circle" coords="492,1593,50" alt="kerala" href="kerala.html"/> </map> </body> </html> KERALA.html <html> <head> <title>india</title> <body bgcolor="yellow" a lign="center"> <img src="kerala.jpg" alt="kerala"/> <ol> <li>kerala is famous for banana chips</li> <li>it has sabari malai</li> </ol> </body> </html> TAMILNADU.html <html> <head> <title>india map</title> </head> <body bgcolor="green" align="center"> <h1>tamilnadu</h1> <img src="tamilnadu.jpg" alt="tamilnadu"/> <p>tamilnadu is the best state in indiait has chennai as its capital.it s known for its temples </p> </body> </html> OUTPUT: RESULT: EX NO: 2 CASCADING STYLE SHEETS PROGRAM: EXTERNAL.CSS body{background - color:green;} p{color:blue;} h3{color:white;} ul.a {list - style - type: square;}<! -- Desendent Selector Element ul followed by class (.a) -- > ul.b {list - style - type: circle;} ol.c{list - style - type:upper - roman;} ol.d{list - styl e - type:lower - alpha;} #hi{text - color:white;}<! -- Id Selector -- > body{background - image:url('tamilnadu.jpg');} h1{text - align:center;}<! -- Type Selector -- > p.date{text - align:right;}<! -- Desendent Selector -- > EXTERNAL.HTML <html> <head> <link rel="stylesheet" type ="text/css" href="ext.css"/><! -- Links External Style Sheet ext.css -- > </head> <body> <h1>EXTERNAL STYLE SHEET</h1> <h3>a white header</h3> <ul class="b"> <li>liststyletype - circle</li> <li>liststyletype - circle</li> <li>liststyletype - circle</li> </ul> <ol class="c"> <li>upper - roman</li> <li>upper - roman</li> </ol> <ol class="d"> <li>lower_alpha</li> <li>lower_alpha</li> </ol> <p class="date"> This paragraph has a blue font .the back ground colour is green because of external style sheet</p> </body> </html> INTERNAL.HTML <html> <head> <style> body{background - color:grey;} p{color:white;} ul.a {list - style - type: circle;} ul.b {list - style - type: square;} #p1{font - family:"Times New Roman",Times,serif;} </style> </head> <body><! -- Type Selector -- > <center> <h2>INTERNAL STYLE SHEET</h2> </center> <ul class="b"><! -- Desendent Selector Element ul followed by class (.b) -- > <li>liststyletype:square</li> <li>liststyletype:square</li> </ul> <p id="p1">This page USES internal css using style tag</p><! -- ID Selector -- > </body> </html> INLINE.html <html> <head> <title>inline css</title> </head> <BODY style="background - color:red";><! -- INLINE Stylesheet style keyword as an attribute -- > <center> <h2>INLINE STYLE SHEET</h2></center> <p style="color:blue;margin - left:20px">< ! -- INLINE Stylesheet style keyword as an attribute -- > This page uses inline css using style attribute<BR/> Inline Style Sheet has the highest priority amomg all style sheets<BR/> Text color is blue and margin left width is 20px. </p></body></html> OUTPUT RESULT: Ex. No :3 DESIGN A WEB SITE USING HTML AND DHTML. USE BASIC TEXT FORMATTING, IMAGES FORMS(INCLUDING CLIENT VALIDATION), FRAMES, LINKS, TABLES ETC. SignUp.HTML: <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http - equiv="Content - Type" content="text/html; charset=utf - 8" /> <title>Untit led Document</title> </head> <body> <center> <img src="Penguins.jpg" alt="image1" width="20%" height="15%" /> <h1> Welcome to my website!!! </h1> Please <b><i><abbr title="Sign Up for Form registration" ><a href="Frames.html">Sign <sup>up</sup></a></abbr></i></b> here </center> </body> </html> Frames.HTML: <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> <html> <head> <meta http - equiv="Content - Type" content="text/html; charset=utf - 8" /> <title>Untitled Document</title> </head> <frameset cols="35,35" rows="*"> <frame id="fr1" src="Form.html" NAME="Left frame" > <frame id="fr2" src="Default.html" NAME="Right frame" > < /frameset><noframes></noframes> </html> Form.HTML: <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http - equiv="Content - Type" content="text/html; charset=utf - 8" /> <title>Untitled Document</title> <script type="text/javascript"> function check() { var name1=document.getElementById("uname").value; if(name1.length<1) { window.alert("Field should be filled"); f1=0; } var re=new RegE xp("^[0 - 9]"); if(re.test(name1)) { window.alert("User name should not start with a digit"); f1=0; } } function check1() { var name1=document.getElementById("passwd").value; if(name1.length<1) { window.alert("Field should be filled"); f1=0; } } function check2() { var name2=document.getElementById("c_passwd").value; var name1=document.getElementById("passwd").value; if(name2.length<1) { window.alert("Field should be filled"); f1=0; } if(name1!=name2) { window.alert("Password mismatch"); f1=0; } } </script> </head> <body> <center> <h2> Form Registration</h2> <form name="f1" ACTION="Response.html" target = "Right frame"> <table border=1> <tr> <td>UserName</td> <td><input type="text" id="uname" name="name" placeholder="your name*" onblur="check()" /> </td> </tr> <tr> <td>Password</td> <td><input type="password" id="passwd" placeholder="Enter password*" onblur="check1()" /> </td> </tr> <tr> <td>Confirm Password</td> <td><input type="password" id="c_passwd" placeholder="Confirm password*" onblur="check2( )" /> </td> </tr> <tr> <td> </td> <td> <input type="submit" value="submit" /> </td> </tr> </table> </form> </center> </body> </html> Default.HTML: <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http - equiv="Content - Type" content="text/html; charset=utf - 8" /> <title>Untitl ed Document</title> </head> <body> <h2> Collecting Details... </h2> </body> </html> Response.HTML: <!DOCTYPE html PUBLIC " - //W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1 - transitional.dtd"> <html xmlns="http://www.w3.org/1999 /xhtml"> <head> <meta http - equiv="Content - Type" content="text/html; charset=utf - 8" /> <title>Untitled Document</title> </head> <body> <h2> Welcome </h2> <h2> Registration Successful </h2> </body> </html> OUTPUT: RESULT: EX NO: 4 INSTALLATION OF APACHE TOMCAT WEB SERVER AIM: PROCEDURE: Steps 1. Double click the exe file and follow the steps by clicking next. The easiest way is to simply download and run the 32 - bit/64 - bit Windows Service Installer of the latest version on Apache Tomcat. In my case the latest version of Apache Tomcat is 7 and the download link is : http://mirrors.hostingromania.ro/apache.org/tomcat/tomcat - 7/v7.0.26/bin/apache - tomcat - 7.0.26.exe Run this file if you agree with the license terms and switch to the Full type of in stall so all the optional components are checked in the following screen: ● If you now click on Next you get the following screen: ● The only think you have to do here is to fill a “User Name”, provide a “Password” for it and eventually tick on the checkbox for “Create shortcuts for all users”. Leave everything as is. Normally you don’t need to change anything. Click on Next. 2. Tomcat uses an environment variable named JAVA_HOME to indicate the location of the JAVA directory. 3. Additionally it uses another environment variable named CATALINA_HOME to indicate the location of Tomcat’s Jakarta level directory. 4. In Windows XP (or equi valent) go to: ● Control Panel 🡪 System 🡪 Advanced 🡪 Environment Variables ● Click on the New button to add the following as seen with the screen grab attached: Just these two need to be added to whatever you have already. CATALINA_HOME c: \ tomcat6 \ apache - tomcat - 6.0.20 JAVA_HOME c: \ program files \ java \ jdk1.6 5. 5. Save the modifications and re - boot your computer to apply the new environment variable settings. 6. This can be tested from the command prompt (Start 🡪 Run and type cmd<Enter>) by typing ECHO followed by a space and then the variable enclosed inside a pair of % characters (e.g. ECHO % JAVA_HOME%). 7. Starting and Stopping the server: ● This is done via two batch files – startup and shutdown ● They can be found i n the Tomcat bin folder. It is recommended you create a shortcut for each and place on your desktop. ● Start the server by running the startup batch file – you should get a display like this: 8.Next test that the server can run a JSP page. In the webapps \ ROOT \ folder you will find an index.jsp file. The ROOT folder is where the JSP pages need to live. Open your web browser and in offline mode type the following in the url text box: http://localhost:8080/index.jsp If the following page appears then you have successfully installed Tomcat: 9. If the page does not appear then there is a problem and you should check all the steps you have made. 10. Finally, shut down the server when not in use by simply running the shutdown batch file. RESULT: EX NO: 5A INVOKE SERVLET FROM HTML PROGRAM CODE: Newhtml.html <html> <body> <form action="gotoservlet1" method="get"><center> Name:<input type="text" name="uname"/><br><br> Age:<input type="text" name="uname2"/> <input type="submit" value="submit"/></center> </form> </body> </html> gotoservlet1.java import java. io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class gotoservlet1 extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF - 8"); try (PrintWriter out = response.getWriter()) { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet gotoservlet1</title>"); out .println("</head>"); out.println("<body>"); out.println("<h1>"+request.getParameter("uname")+ "</h1>"); out.println("<h1>"+request.getParameter("uname2")+ "</h1>"); out.println("</body>"); out.pri ntln("</html>"); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; }// </editor - fold> } OUTPUT: RESULT: EX NO: 5B SESSION TRACKING USING HIDDEN FORM FIELDS PROGRAM CODE: index.html <html> <head> <title>TODO supply a title</title> <meta charset="UTF - 8"> <meta name="viewport" content="width=device - width, initial - scale=1.0"> </head> <body> <form action="servlet1"><center> Name:<input type="text" name="uname"/><br/><br><br> <input type="submit" value="go"/> </form> </body> </html> servlet1.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; @WebServlet(urlPatterns = {"/servlet1"}) public class servlet1 extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletExcep tion, IOException { response.setContentType("text/html;charset=UTF - 8"); try (PrintWriter out = response.getWriter()) { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet servlet1</title>"); out.println("</head>"); out.println("<body>"); String n=request.getParameter("userName"); out.println("<h2><center>"); out.print("Wel come "+n +"<br> This is displayed from normal request object <br>Now.. Creating an invisible field"); //creating form that have invisible textfield out.print("<form action='servlet2'>"); out.print("<input type='hidden' name ='uname' value='"+n+"'>"); out.print("<input type='submit' value='go'>"); out.print("</form>"); out.close(); out.println("</body>"); out.println("</html>"); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, Http ServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; }// </editor - fold> } servlet2.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.HttpSe rvletResponse; @WebServlet(urlPatterns = {"/servlet2"}) public class servlet2 extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF - 8"); try (PrintWriter out = response.getWriter()) { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<t itle>Servlet servlet2</title>"); out.println("</head>"); out.println("<body>"); out.println("<h2><center>"); String n=request.getParameter("uname"); out.print("Hello "+n); out.println("<br> This is displayed from the hidden field"); out.println("</body>"); out.println("</html>"); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; }// </editor - fold> } OUTPUT: RESULT: EX NO: 5C SESSION TRACKING USING SESSION ATTRIBUTES PROGRAM CODE: index.html <html> <head> <title>TODO supply a title</title> <meta charset="UTF - 8"> <meta name="viewport" content="width=device - width, initial - scale=1.0"> </head> <body> <form action="hi" method="get"> <br><br><center><input type="submit" value="click me"> </form> </body> </html> hi.java import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServle t; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @WebServlet(urlPatterns = {"/hi"}) public class hi extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF - 8"); try (PrintWriter out = response.getWriter()) { // Get the current session object, create one if necessary HttpSession session = request.getSession(true); // Increment the hit count for this page. The value is saved // in this client's session under the name "tracker.count". Integer count = (Integer)session.getValue("tracker.count"); if (count == null) count = new Integer(1); else count = new Integer(count.intValue() + 1); session.putValue("Count tracker: ", count); out.println("<HTML><HEAD><TIT LE>SessionTracker</TITLE></HEAD>"); out.println("<BODY><center><H2>Welcome to Session Tracking </H2>"); // Display the hit count for this page out.println("You've visited this page " + count + ((count.intValue() == 1) ? " time." : " times .")); out.println("<P>"); out.println("<H2>Here is your session data:</H2>"); String[] names = session.getValueNames(); for (int i = 0; i < names.length; i++) { out.println(names[i] + ": " + session.getValue(names[i]) + "<BR>"); } out.println("<a href= \ "hi \ ">click me to visit again</a>"); out.println("</BODY></HTML>"); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOExceptio n { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; }// </editor - fold> } OUTPUT: