IP LAB MANUAL CS6512.pdf

October 5, 2017 | Author: gopivrajan | Category: Java Servlet, Ajax (Programming), Html Element, Java Server Pages, Websites
Share Embed Donate


Short Description

Download IP LAB MANUAL CS6512.pdf...

Description

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

LAB MANUAL

CS6512 – INTERNET PROGRAMMING LABORATORY (R2013) V – SEMESTER – CSE

Prepared by Mr.Gopirajan.P.V Asst Prof / CSE

SYLLABUS CS6512

INTERNET PROGRAMMING LABORATORY

L T PC 0 0 3 2

OBJECTIVES: The student should be made to: Be familiar with Web page design using HTML/XML and style sheets Be exposed to creation of user interfaces using Java frames and applets. Learn to create dynamic web pages using server side scripting. Learn to write Client Server applications. Be familiar with the frameworks JSP Strut, Hibernate, Spring Be exposed to creating applications with AJAX LIST OF EXPERIMENTS



IMPLEMENT THE FOLLOWING:

WEBPAGECONCEPTS a) Create a web page with the following using HTML

a. To embed a map in a web page b. To fix the hot spots in that map c. Show all the related information when the hot spots are clicked. b) Create a web page with the following. a. Cascading style sheets. b. Embedded style sheets. c. Inline style sheets. Use our college information for the web pages.

c) Create and save an XML document at the server, which contains 10 users information. Write a Program, which takes user Id as an input and returns the User details by taking the user information from the XML document. SOCKETS & SERVLETS a) Write programs in Java using sockets to implement the following: i. HTTP request

ii. FTP iii. SMTP iv. POP3 b) Write a program in Java for creating simple chat application with datagram sockets and datagram packets. c) Write programs in Java using Servlets:

i. To invoke servlets from HTML forms ii. To invoke servlets from Applets d) Write programs in Java to create three-tier applications using servlets for conducting on-line examination for displaying student mark list. Assume that student information is available in a database which has been stored in a database server. e) Write a program to lock servlet itself to a particular server IP address and port number. It requires

an init parameter key that is appropriate for its servlet IP address and port before it unlocks itself and handles a request f) Session tracking using hidden form fields and Session tracking for a hit count. g) Install TOMCAT web server. Convert the static webpages of programs 1&2 into dynamic web pages using servlets (or JSP) and cookies. Hint: Users information (user id, password, credit card number) would be stored in web.xml. Each user should have a separate Shopping Cart. ADVANCECONCEPTS: a) Implement a simple program using following frameworks

a. JSP Struts Framework b. Hibernate c. Spring b) Explore the following application in AJAX: Searching in real time with live searches, Getting the answer with auto complete, Chatting with friends ,Dragging and dropping with Ajax, Getting instant login feedback, Ajax-enabled popup menus, Modifying Web pages on the fly. c) Write a web services for finding what people think by asking 500 people’s opinion for any consumer product

d) Write a web services for predicting for any product sales OUTCOMES: At the end of the course, the student should be able to Design Web pages using HTML/XML and style sheets Create user interfaces using Java frames and applets. Create dynamic web pages using server side scripting. Write Client Server applications. Use the frameworks JSP Strut, Hibernate, Spring Create applications with AJAX

TOTAL: 45 PERIOD

REFERENCE: spoken-tutorial.org. LIST OF EQUIPMENT FOR A BATCH OF 30 STUDENTS: SOFTWARE: Java, Dream Weaver or Equivalent, MySQL or Equivalent, Apache Server HARDWARE: Standalone desktops 30 Nos

CS6512 – INTERNET PROGRAMMING LABORATORY (R2013)

EXPT. NO.

TITLE OF THE EXPERIMENTS

1.

Creating a Web Page using Image Map

2.

Write a webpage that displays college information using various style sheet Style Sheets

3.

Write a DHTML code for creating the web page for validating the web form

4.

Write a java program to create the applets

5.

Write a java program to create a color palette with the matrix of Buttons

6.

Write a java program for invoking servlet from HTML form

7.

Write a program for invoking servlet from HTML form.

8.

Write the JSP program for online examination

9.

Write a XML scheme to generate CD Collection details

10.

Write a java script program for a AJAX

11.

Implement a application using the web services

LEARNINGOBJECTIVES The objective of this lab is to provide a student with an understanding of the fundamental concepts in internet programming and to provide the skills needed for developing web based application with Java platform. They can also have knowledge of the underlying generic principles of computer programming as applied to implementing basic web-based applications.

INTRODUCTION JAVA Java is one of the most popular programming languages used to create Web applications and platforms. It was designed for flexibility, allowing developers to write code that would run on any machine, regardless of architecture or platform. According to the Java home page, more than 1 billion computers and 3 billion mobile phones worldwide run Java. HTML Hypertext Markup Language (HTML) is the main markup language for creating web pages and other information that can be displayed in a web browser. HTML is written in the form of HTML elements consisting of tags enclosed in angle brackets (like ), within the web page content. HTML tags most commonly come in pairs like and , although some tags represent empty elements and so are unpaired, for example . The first tag in a pair is the start tag, and the second tag is the end tag (they are also called opening tags and closing tags). In between these tags web designers can add text, further tags, comments and other types of text-based content. CSS Cascading Style Sheets, more commonly known by the abbreviation CSS, are style sheets that are linked to the XHTML (Extensible Hypertext Markup Language) of the website. The CSS code allows Web developers to take control of many aspects of their site, such as fonts, colors, positioning and styling of data, while the XHTML code of the site deals with the actual content and structure of the website. JAVASCRIPT Javascript is an easy-to-use programming language that can be embedded in the header of your web pages. It can enhance the dynamics and interactive features of your page by allowing you to perform calculations, check forms, write interactive games, add special effects, customize graphics selections, create security passwords and more. SERVLET The Servlet is a Java programming language class used to extend the capabilities of a server. Although servlets can respond to any types of requests, they are commonly used to extend the applications hosted by web servers, so they can be thought of as Java Applets that run on servers instead of in web browsers. These kinds of servlets are the Java counterpart to other dynamic Web content technologies such as PHP and ASP.NET. JSP - Java Server Page: It is a server-side technology; Java Server Pages are an extension to the Java servlet technology that was developed by Sun. JSPs have dynamic scripting capability that works in tandem with HTML code, separating the page logic from the static elements -- the actual design and display of the page -- to help make the HTML more functional (i.e. dynamic database queries). A JSP is translated into Java servlet before being run, and it processes HTTP requests and generates responses like any servlet. However, JSP technology provides a more convenient way to code a servlet. Translation occurs the first time the application is run. A JSP translator is triggered by the .jsp file name extension in a URL. JSPs are fully interoperable with servlets. You can include output from a servlet or forward the output to a servlet, and a servlet can include output from a JSP or forward output to a JSP. JSPs are not restricted to any specific platform or server. It was orignially created as an alternative to Microsoft's ASPs (Active Server Pages). Recently, however, Microsoft has countered JSP technology with its own ASP.NET, part of the .NET initiative. AJAX an acronym for Asynchronous JavaScript and XML) is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not required (JSON is often used instead. See AJAJ), and the requests do not need to be asynchronous

CS6512 INTERNET PROGRAMMING LAB LIST OF EXPERIMENTS 1.Create a web page with the following using HTML i) To embed an image map in a web page ii) To fix the hot spots iii) Show all the related information when the hot spots are clicked. 2. Create a web page with all types of Cascading style sheets. 3. Client Side Scripts for Validating Web Form Controls using DHTML 4. Write programs in Java to create applets incorporating the following features: 5. Create a color palette with matrix of buttons Set background and foreground of the control text area by selecting a color from color palette. In order to select Foreground or background use check box control as radio buttons To set background images 6. Write programs in Java using Servlets: To invoke servlets from HTML forms To invoke servlets from Applets 7. Write programs in Java to create three-tier applications using JSP and Databases for conducting on-line examination for displaying student mark list. Assume that student information is available in database which has been stored in a database server. 8. Programs using XML – Schema – XSLT/XSL 9. Programs using AJAX 10. Consider a case where we have two web Services- an airline service and a travel agent and the travel agent is searching for an airline. Implement this scenario using Web Services and Data base.

www.studentsfocus.com 1

Ex. No: 1

DATE:

IMAGE MAPPING AIM: To write a map and fix the hotspots to show the information of it in a web page. ALGORITHM: 1. Start the program. 2. Get the india map image and link it to the package.

3. Fix the hotspots in that image. 4. Map the reference of the hotspots in the image.

5. Mention the derived link. 6. Click the link to get the desired image. 7. Stop the program. SOURCE CODE: Main.html

www.studentsfocus.com 2

Tamiladu.html it is a tamilnadu,here maximum tamilan living and capital of tamilnadu is chennai Kerala.html it is a kerala,here maximum malaiyalees living and capital of kerala is Thiruvananthapuram Karataka.html it is a karnataka,here maximum kannadam living and capital of karnataka is Bangalore Madhyapradesh.html it is a madhyapradesh,here maximum maratiyam living and capital of madhyapradesh is BHOPAL Maharastra.html it is a maharashtra,here maximum maratiyam living and capital of maharashtra is Mumbai

www.studentsfocus.com 3

Orissa.html it is a orissa,here maximum oreya living and capital of orissa is Bhubaneswar

Output:

www.studentsfocus.com 4

RESULT: Thus the web page is created and the image is embedded with hot spot and the linking ages successfully, and the output is verified.

www.studentsfocus.com 5

Ex. No: 2

DATE:

STYLE SHEET AIM: To write a webpage that displays college information using various style sheet. ALGORITHM: 1. Start the program. 2. Create a web page with framesets consisting two frames. 3. In the first frame include the links. 4. In the second frameset display the webpage of the link. 5. Create a external style sheets. 6. Create a inline and internal style and make a link to the external style sheet. 7. Stop the program. SOURCE CODE: Cascading Style Sheets Different types of Cascading Style Sheets 1. Inline Style Sheet 2. Embeded Style Sheet 3. External Style Sheet 4. Imported Style Sheet Inline.html Inline Style Sheet Inline Style Sheet

www.studentsfocus.com 6

Inine Style is the style attached to one specific element. The style is specified directly in the start tag as a value of the style attribute well apply exclusively to this specific element occurrence. Embedded.html Embeded Style Sheet ol{list-style-type:decimal} h1{text-align: left; background:antiquewhite;font-family:monotype corsiva;color:red} h3{text-align: right; font-family:arial;color:blue} Embedded style sheet Embedded style is the style attached to one specific document. The information is specified as a content of the style element inside the head element and wil apply to the entire documents. External.html External Style Sheet 1. External Style Sheet An external style sheet is a template documents/files containing style info which can be linked with any number of the documents. This is a very convenient way of formating the entire site as well as restyling it by editing just one file Import.html Imported Style Sheet

www.studentsfocus.com 7

1. Imported Style Sheet Imported style sheet is a shet that can be imported to another sheet. This alignes exacting one main sheet containing declarations that apply to the whle site and partial sheets containing declarations that apply to specific elements. Output:

www.studentsfocus.com 8

www.studentsfocus.com 9

RESULT: Thus the web page is created using all tyes of cascading style sheets successfully and the output is also verified.

www.studentsfocus.com 10

EX. No: 3

DATE: WEB FORM VALIDATION

AIM: To write a DHTML code for creating the web page for validating the web form. ALGORITHM: 1.The form will include one text field called "Your Name", and a submit button. 2.Validation script will ensure that the user enters their name before the form is sent to the server. 3.Open this page to see it in action. 4.Try pressing the Send Details button without filling anything in the "Your Name" field. 5.You might like to open the source code for this form in a separate window 6.The page consists of a JavaScript function called validate_form() that performs the form validation, followed by the form itself. SOURCE CODE: A Simple Form with JavaScript Validation Please Enter Your Name Your Name:

www.studentsfocus.com 11

OUTPUT:

www.studentsfocus.com 12

RESULT: Thus the program has been written for creating the web page for validating the informations.

www.studentsfocus.com 13

Ex.No:4

DATE: APPLET CREATION

AIM: To write a java program to create the applets. ALGORITHMS: 1.Write a HTML applet tag with code set, class name, and comment the tag. 2.Import all necessary packages and classes. 3.Define a class that extends applet and implements action listener and item listener. 4.Declare an array of buttons to set colors , two check boxes for foreground and background colors. 5.Declare a text area to hold the text, a check box group for check boxes. 6. Declare three panels, button panel, palette panel and check pael. 7. Declare a string, color. 8.Display the result. 9.Stop the program. SOURCE CODE: import javax.swing.*; import java.awt.event.*; import java.awt.*; /* */ public class colour extends JApplet implements ActionListener { JPanel p,p1; JButton b,b1,b2,b3; Checkbox c,c1; TextArea area; Color d=new Color(255,0,0); Color d1=new Color(0,255,0); Color d2=new Color(0,0,255); Color d3=new Color(255,177,76); GridLayout g; public void init() { p=new JPanel(); p1=new JPanel(); g=new GridLayout(2,2); p1.setLayout(g); b=new JButton(); b1=new JButton();

www.studentsfocus.com 14

b2=new JButton(); b3=new JButton(); b.setBackground(d); b1.setBackground(d1); b2.setBackground(d2); b3.setBackground(d3); area=new TextArea(" Welcome To Colour Palate ",25,25); CheckboxGroup cbg=new CheckboxGroup(); c=new Checkbox(" ForeGround ",cbg,true); c1=new Checkbox(" BackGround ",cbg,false); p.add(c); p.add(c1); p.add(area); p1.add(b); p1.add(b1); p1.add(b2); p1.add(b3); p.add(p1); getContentPane().add(p); b.addActionListener(this); b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); } public void actionPerformed(ActionEvent e) { Object obj=e.getSource(); if(obj==b) { if(c.getState()==true) area.setForeground(d); else area.setBackground(d); } if(obj==b1) { if(c.getState()==true) area.setForeground(d1); else area.setBackground(d1); } if(obj==b2) { if(c.getState()==true) area.setForeground(d2); else

www.studentsfocus.com 15

area.setBackground(d2); } if(obj==b3) { if(c.getState()==true) area.setForeground(d3); else area.setBackground(d3); }}} OUTPUT:

www.studentsfocus.com 16

www.studentsfocus.com 17

Ex. No: 5

DATE:

COLOR PALETTE. AIM:

x x x x x x

To write a java program to create a color palette with the matrix of Buttons. Set the background and foreground of the control unit area By selecting a color from color palette. In order to select foreground (or) background are checkbox Control as radio buttons. To set background images.

ALGORITHM: 1. Import the package that are necessary to create an palette color. 2. Allocate memory location for buttons and checkbox group by Using new keyword. 3. Set the background and by using the background. 4. Add the component color by using add method. 5. Call the methods for listening the action. 6. The getimage method is used to get the image and displayed Onto the screen. 7. Compile and run the program. SOURCE CODE: import java.awt.*; import java.applet.*; import java.awt.event.*; /**/ public class colorpl extends Applet implements ItemListener { int currcolor=5; int flag=1; String text="click any of the button"; Button buttons[]=new Button[5]; String colors[]={"red","blue","green","yellow","magenta"}; Image img; CheckboxGroup cbg=new CheckboxGroup(); Checkbox box1=new Checkbox("Background color",cbg,true); Checkbox box2=new Checkbox("Text color",cbg,false); Checkbox box3=new Checkbox("Loading Image", cbg, false); public void init() { for(int i=0;i
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF