You are on page 1of 29

Q.1 Give one example each for the following and explain the use in one/two tine each.

1. Web Design Tools 1. Web Design Tools, 2. HTML Editors, 3. Adobe Photoshop, 4. Adobe Flash, & 5. FirebugBrowser1. Web Design Tools: Design for the Web is one of the most significant areas that are emergingin the development of websites. Web design refers to the task of developing a Web page or theuser interface of the Web page. The design of a Web page acts as a medium between people andinformation. The major intention of Web design is in the development of attractive Web pagesthat reside on Web servers. Web design tools concentrates more on the presentation of contentsusing hypertext, images, videos, and so on.There are various tools available today that help us develop and design Web pages. We can termthese as design tools. Design tools help us to design attractive Web pages easily and quickly.Some of the popular Web design tools are as follows:HTML Editors.Adobe Photoshop.Adobe Flash.Firebug Browser. 2. HTML Editors: HTML editor refers to a software application that we can use to create Webpages. It provides us with various tools that are required to design a Website. Even though theHTML files can be written using any text editor such as notepad or textpad, specialised HTMLeditors can provide convenience and additional functionalities. It not only offers support to work with HTML tags but also provides support to work with technologies such as Cascading StyleSheets (CSS), Extensible Mark-up Language (XML) and JavaScript. They even help us to handlethe interactions that happen with remote Web server through the File Transfer Protocol (FTP)and Web-based Distributed Authoring and Versioning (WebDAV). HTML Editor is useful as weneed not have to type or remember all the HTML tags. We can say that it is just like the wordprocessor where we type the content and apply the required formats. We can see the HTMLsource as well as view how the Webpage would look like when viewed on the Web browser, byswitching to the display format.

3. Adobe Photoshop: Adobe Photoshop is a software application package useful in editingimages and is considered as an important tool for Web designing. It is an excellent tool to createattractive Websites. Photoshop can read and write raster and vector image formats. For example,gif, jpeg and png. An image in raster format is described in a table of pixels, where each pixelhas a specific color. Adobe Photoshop is considered as an image editing tool for Web design as it useful in thefollowing ways: 1. It helps you to tune your art work to the design of your a Web page on your Website.2. It can be used to add graphics to your videos that you might have uploaded on yourWebsite.3. It helps to create different types of web banners and buttons that would enhance the look of your Website.4. It also helps us to turn an image or photograph look like a work of art, that is, to look likea painting.5. It can be used to create a rollover effect to the images or button on your Web pages easilywithout writing any code by just adding different behaviours to different images orbuttons. Here, by rollover effect we mean that we can make a particular area of an imageto change when you click or move the mouse over an image. 4. Adobe Flash:Adobe Flash is a multimedia graphics program that is used to create interactiveWeb pages, videos and animations. It can be embedded inside any HTML program to createinteractive Web pages. Other than being used for creating interactive Web pages it is also widelyused in games and advertisements.Adobe Flash helps you to create

interactive videos on the Web. It uses vector graphics. Here,vector graphics refers to graphics that can be scaled to any size of our choice without any loss inquality or clarity. We need not have any kind of programming knowledge to use this software asit is very easy to learn. It captures user input through keyboard, mouse, microphone and camera. We will now look into some of the uses of Adobe Flash. Some of the uses of Adobe Flash areas follows:

Top Five Web Design Tools Mar 15 2009 by Jacob Gube |137 Comments |StumbleBookmark

advertise here Just like in most other professions, a web designers set of tools is what brings a concept into fruition. There are many applications available to our disposal, but there are some that just stand out from the crowd. The tools in this article are whats regarded as the most popular tools used for web design. Last week, you were asked to vote on what you thought was the best web design tool. Close to 280 of you shared your opinion on what the best web design tool is. In this article, youll find the five web design tools that garnered the most votes. 5. Fireworks

Adobe Fireworks is a commercial raster and vector graphics editor hybrid from Adobe thats available for the Mac and Windows operating systems. Designed specifically for web designers (unlike Photoshop), Fireworks brings you a plethora of tools and options that make full web layout prototyping a breeze. Among its notable features are: "slices" for slicing and dicing a design mockup into HTML/CSS for rapidly creating prototypes (though you should avoid using auto-generated source code for the end-build), the ability to package an entire site design as a PDF with clickable components for interactive and impressive site prototypes, and optimization tools for making your web graphics as lightweight as possible. 4. Dreamweaver

Adobe Dreamweaver is a commercial application for web development thats available for the Mac and Windows operating systems. Its featured-packed suite of tools and options include: syntax highlighting and very smart Code Hinting, a built-in FTP client, project management and workflow options that make team work effortless, and Live View which shows you a preview of your source code. Dreamweaver tightly integrates with other popular Adobe

products such as Photoshop, allowing you to share Smart Objects for quick and easy updating and editing of graphics components. 3. Panic Coda

Panic Coda is a shareware web development application for the Mac OS X operating system. It seeks to reduce the amount of applications (such as an FTP client, CSS editor, a version control system, etc.) you need to develop websites and to improve your teams workflow. Codas one-window web development philosophy uses a tabbed interface for text editing, file transfers, SVN, CSS, and even "Books" which embeds web books that are searchable (it comes with The Web Programmers Desk Referencebut you can add your own). Its simple and intuitive interface allowed Coda to garner the Apple Design Awards Best Mac OS X User Experience in 2007. 2. Photoshop

Adobe Photoshop is a very popular commercial graphics editor available for the Mac and Windows operating system. Created for professional photographers and designers, it is the ideal application for manipulating images and creating web graphics. Photoshop has all the necessary tools and options you need such as: Filters which automatically adds effects to

your image or a selected section of your image, extensibility and automation with Brushes, Actions and Scripting, and workflow enhancement features like Layer Comps and the Revert option. 1. Firebug

Firebug is a free, open source in-browser web development tool for the Firefox web browser. Its many features include: on-the-fly HTML and CSS editing for tweaking or debugging, a Console for logging, analyzing and debugging JavaScript, and an intuitive Document Object Model (DOM) inspection tool to help you quickly see how the elements of a web page relates to one another. Firebugs popularity is so immense its one of the few Firefox extensions that have its own extensions (like YSlow and FirePHP)!

2. HTML Editors An HTML editor is a software application for creating web pages. Although the HTML markup of a web page can be written with anytext editor, specialized HTML editors can offer convenience and added functionality. For example, many HTML editors work not only with HTML, but also with related technologies such as CSS, XML and JavaScript or ECMAScript. In some cases they also manage communication with remote web servers via FTP and WebDAV, and version management systems such as CVS or Subversion. Contents [hide]
o o o

1 Types of editors 1.1 Text editors 1.2 Object editors 1.3 WYSIWYG HTML editors

o o

1.4 WYSIWYM editors 1.5 Online editors 2 Valid HTML markup 3 Difficulties in achieving WYSIWYG 4 See also 5 References

3. Adobe Photoshop 45 Brilliant Examples of Photo Manipulation Art By Noupe Editorial Posted in Photography, PHOTOSHOP 288 comments Advertisement

Photo manipulation is probably one of the most popular application areas in which Adobe Photoshop is used extensively. One of the main reasons for that is its ability to blend real photos with vibrant colors and digital painting to emphasize some beautiful details which makes this software ideal for this kind of work. Here are 45 incredible examples of Photo manipulated images from extremely talented Photoshop artists. Chog

by Jenny Leigh

Resources for Adobe Photoshop users including tips, tutorials, free downloads, actions, plug-ins, training and support. 43. Photoshop CS2 Basics Course (15) 44. Photoshop Video Tutorials (59) 45. Adobe Bridge File Browser 46. Photoshop Quick Tips (46) 47. Essential Tutorials (454) 48. Free Photoshop Downloads (306) 49. Photoshop Books & Videos (12) 43. Photoshop Color Management (11) 44. Troubleshooting Photoshop (16)

45. Photoshop Add-ons & Tools (20) 46. Top-Notch Photoshop Sites (7) 47. Adobe Photoshop Elements 48. Plug-ins and Filters 49. More Adobe Software 4. Adobe Flash 45+ Excellent Examples of Flash Websites Design Ads

Talking about website design, Flash website could be the most very attractive as it catch every peoples eye for its flashy and animated effect. On this matter I made a list of 45+ Excellent Examples of Flash Websites Design as for more inspirations. These sites are hand picked and a best example of flash websites on the web. Make sure to turn your speaker ON as most of these flash websites are using cool audio as well. Raymanzone

5. Firebug Browser [ Client Debugging Firebug is the most commonly used debugger, but it is not the only debugger available. Safari and Chrome both have good console tools for developers. This page uses Firebug examples. Many of the techniques in other consoles are similar. Seedebugging for information about other debuggers for other browsers.

About Firebug Activate Firebug for Javascript debugging Firebug Error Status Bar Use Console to execute Javascript directly Explore JavaScript objects Debug database, web and other service calls to the server Running WaveMaker Studio in Debug Mode Printing to the Console Setting Breakpoints in your page code o Setting Breakpoints in Start() Using console inside of WaveMaker Studio Debugging With pageContainers See Also

About Firebug The Firefox add-on, Firebug, provides several useful debugging tools. it is strongly recommended that you have Firebug enabled while developing with WaveMaker. To download Firebug, go to: http://getfirebug.com/ Firebug is a debugger that runs in the Firefox browser. It is invaluable for debugging any Javascript application and a necessary tool for advanced WaveMaker development. Before you start doing Javascript programming in WaveMaker, download the Firefox browser and the Firebug plugin or add a bookmark in your browser for firebug lite. See the GetFirebug.com Wiki for firebug documentation. Activate Firebug for Javascript debugging Once Firebug is installed, you will see a bug button in the lower right corner of your Firefox browser window. To activate Firebug, run your WaveMaker application, then press the Firebug button and reload the page.

Firebug Error Status Bar Firebug lets you know of errors within your application with a status bar error indicator. Watching the status bar indicator will quickly let you know when there is a problem.

Use Console to execute Javascript directly You can enter Javascript into the Firebug console and execute it immediately. The following example shows getting the value of a textEditor widget.

You can enter multiple lines of Javascript, so this is a good way to test out Javascript before you add it to the source of your WaveMaker application. Click the Console tab within FireBug and type your JavaScript at the command prompt. Here are a few suggestions:

To enable debug information on studio widgets, use: wm.logging=true; To use Firebug to directly inspect components or widgets at design time, use: studio.page.widgetname For example, to null the data value of an editor1 on the main page from the Firebug console use: studio.page.editor1.setValue("dataValue", null); To use Firebug to directly inspect global Variables at design time, use: studio.page.app.variablename Note: Note that within the Firebug console, you cannot use "this" to refer to the current page. Instead, you need to use "studio.page".

You can get a lot of information at design time, through LiveLayout and through the Firebug console. However, note that page code is not run at design.

To inspect a component at runtime, use the pagename.component syntax for components scoped at the page level: main.label1 or app.component for components scoped at the project level: app.myVariable

Explore JavaScript objects You can access any WaveMaker widget directly from the Firebug console just by typing the name of the widget, preceeded by the name of the page. The default page in a WaveMaker application is called "main", so if you want to access a widget named "editor1", type "main.editor1" into the console. The following example shows entering the name of a widget on the right panel "main.textEditor1", and getting a reference to the object on the left side "wm.TextEditor" - click on this to expand the object and see all of its functions, data elements and data values.

Debug database, web and other service calls to the server Firebug allows you to see the calls your WaveMaker client application is making to the server to invoke database and web services, as well as the response from those calls. Select the "Net" tab in Firebug to see all your database calls. Click on a "Post" call to see the header, post and response for this service. Click on the "post" tab to see what was sent to the server - not that this post is calling the "read" method for the data class "Comment"

Now click on the response tab to see what the server sent back to the client in response to this call. Note that the result is a Json array of 3 comments. This technique allows you to see exactly what data is being sent between the WaveMaker client and the WaveMaker server.

Running WaveMaker Studio in Debug Mode WaveMaker Studio provides two startup options, regular or debug:

The regular mode runs WaveMaker using a Dojo "build" for efficiency. This build combines and compresses the Dojo files into fewer, larger files that are easier for the browser to quickly load and parse. Consequently, those files are more difficult to get meaningful error messages out of in Firebug. The debug mode does not use this Dojo build. In debug mode, the WaveMaker Studio files are uncompressed so that they are more readable. The debug version is very useful for debugging your application with Firebug.

Printing to the Console From within any JavaScript function, informational statements and Variables can be printed out the Firebug console using the built-in Javascript function, console.log(). To log a static string to the console use: // This prints a message to the Firebug console console.log("Hello WaveMaker"+this.editor1.getDataValue()); Setting Breakpoints in your page code The console keyword "debugger" allows you to set breakpoints in your page code before you load the app in firebug. Simply add 'debugger' wherever you would like the app to break execution. For example to break in the page start function, use debugger in start(); dojo.declare("Main", wm.Page, { start: function() { debugger; },

Recent versions of Firebug are much more advanced and have more features than ever before. Debugging your page code requires a few key settings.

Use ?debug mode

See above

Enable 'All' Scripts

Do NOT enable decompile

Clear your cache

Q.2 Write a Java program to demonstrate the use of control statements (all three statemnts) in Java. [10 Marks] 2.2.1 If statements. 2.2.2 Switch Statements. 2.2.3 For loop. 2.2.4 While Statements. 2.2.5 Do statements Ex - 2.2.1 class IfTest { public static void main ( String args [ ] ) { int x = 4; int y = 10; if (x > y )

{ System.out.println ("x is greater than y" ); } else { System.out.println ("X is lesser than y"); } } } Ex - 2.2.2 class SwitchTest { public static void main (String args [ ] ) { char ch = 'A'; switch (ch) { case 'A': System.out.println ("Value is A"); break; case 'B': System.out.println ("Value is B"); break; default: System.out.println ("Unknown Value"); } } Ex 2.2.3 class ForTest { public static void main (String args [ ] ) { int i= 0; int sum = 0; for( i = 0; i <= 10; i++) sum += i; System.out.println ("The sum of first 10 Nos =" + sum ); } } Ex 2.2.4 class WhileTest { public static void main (String args [ ] ) { int i=1; while (i<=5) {

System.out.println ("i =" + i); i++; } } } Ex 2.2.5 class BreakLoop { public static void main (String args [ ]) { int i= 0; do { System.out.println ("Im stuck !" ) ; i++; if (i > 5) break; } while (true); } } Q.3 What are the difference types of inheritance in Java? Explain the relationship between interfaces and inheritances. [10 Marks] 1.Single Inheritance 2.Multiple Inheritance 3.Multilevel Inheritance 4.Hierarchical Inheritance 5.Hybrid Inheritance In single inheritance, a class inherits implementation from only one super class. For example, if class B inherits from class A, class B will acquire all the members declared in class A. B------>A(Parent) In multilevel inheritance, a class inherits from a derived class (or subclass). For example, if class C inherits from class B, and class B inherits from class A, class C will acquire all the members declared in class B as well as all the members declared in class A. C------->B------>A(Parent) In hierarchical inheritance, many sub classes inherit from a single super class. For example, if classes B, C, and D inherit from class A, classes B, C, and D will acquire all the members declared in class A. B------>A(Parent)C------>A(Parent)D------>A(Parent) In multiple inheritance, a class inherits from several super classes. For example, if class C inherits from both class A and class B, class C will acquire all the members declared in class A as well as all the members declared in class B. Multiple inheritance is not directly supported by Java but through Interfaces one can.C------>A(Parent)C------>B(Parent)

A hybrid inheritance is a combination of any two of the above discussed inheritance types Inheritance Vs. Interfaces Many high-level languages support inheritance and interfaces, and for someone new to the concepts, it's sometimes not clear which one to choose. Although languages differ in their exact handling of inheritance and interfaces, the basics are usually the same, so this tip should be valid for most languages. Inheritance means that we derive one class (the derived class) from another class (the base class). The derived class is an extension of the base class. It contains all the features (methods and data members) of the base class, can extend it with new features, and can reimplement virtual methods of the base class. Some languages, like C++, support multiple inheritance, where a derived class can have multiple base classes, but usually inheritance is restricted to a single base class. Interfaces can usually only define methods and no data members (but C# for example allows data members in the form of properties within interfaces), and a class can always implement multiple interfaces. An interface contains only method definitions without implementations, and a class that implements an interface supplies the implementation. So, using inheritance, you write a base class with method implementations, and when you derive a class from it, this class will inherit everything from the base class, and is immediately able to use its features. An interface on the other hand is just a contract of method signatures, and a class that wants to implement an interface is forced to supply the implementations for all methods of the interface. So when do you use which? In some cases, the language already dictates what you use: if you need your class to have multiple 'parents', you cannot use inheritance in languages that don't support multiple inheritance. And if you want to reuse a library object, you have to use the fitting concept, depending on if that library object is a class or an interface. But which to use if you are free to choose? Basically, base classes describe and implement common behavior of related types, while interfaces describe functionality that unrelated types can implement. Inheritance describes 'is a' relationships, interfaces describe 'behaves like' relationships. For example, say that you are writing a flight simulator. Your basic entity, which you will for example store in a list, will be 'Airplane'. Your concrete types will be 'Concorde' and 'Phantom'. So how should you model the three types? Concorde and Phantom are related, they both are airplanes and share data, like 'Weight' or 'MaxSpeed' and functionality, like 'Accelerate', so we can model them with inheritance. 'Airplane' will be the base class with common data and methods, and 'Concorde' and 'Phantom' will derive from 'Airplane'. We could say that both are specialized airplanes, which is why it's often said that inheritance means specialization. Now assume that we also add a class 'Pilot' to our program, and we want to give the user the ability to save the game and load it later. So when he saves the game, we need to save the state of all Aircrafts and the state of all Pilots. And we want to do this in one function that takes just a list of all saveable

objects. So how do we model this? To answer this, we must take a look at the different types we want to save. Pilots and Airplanes. It's obvious that they are not related at all. They share no common data and no common functionality. We can see that writing a base class 'Saveable' and derive both Pilot and Airplane from it would make little sense, since no code in Saveable could be reused by Airplane or Pilot, since both have no common properties. In this case, an interface is the best solution. We can write an interface 'ISaveable' with a method Save(). Pilot could then implement ISaveable.Save() by saving his name, while Airplane could save its current speed and coordinates. As you can see, a clear image of the relationship between classes often makes the choice clear: Use inheritance for related types, where each derived class 'is a' base class. Use interfaces for unrelated types which have some common functionality. Here are some more points to consider with inheritance and interfaces: - Interfaces are fixed. When you change an interface, you have to change every class implementing that interface. But when you change a base class, every derived class will gain the new functionality, which can both be good (if you make a bugfix in some base class method implementation, a derived class using that method will gain the bugfix without you needing to change it) or bad (if a change in the baseclass introduces a new bug, all derived classes using the method will be bugged too). - Interfaces are usually more flexible, since in most languages you can only derive from one class, but implement many interfaces - Interfaces help to protect internal classes: Assume class A has an internal object b of class B. When a method in A returns a pointer or reference to b, the code that called this method now has access to the whole object b, which can be dangerous if A only wants to expose certain members of b. This problem can be solved if you create an interface I with just the members which are safe to expose. When B implements this interface, and your method in A returns b via an I pointer or reference, the outside code can only do what you allow through the interface.

Q.5 Describe the working of search engine. What are the different types of search engine? Explain with its application. [10 Marks] Working of a Search Engine You have now learnt the meaning and origin of a search engine. Let us now study about theworking of a search engine.How do we search for a Web page using any search engine? We open the search engine Websitefor example, www.google.com or www.bing.com and then in the text box provided we type thekeywords of our choice and press enter key or click the search button. This process will provideus a list of Websites based on the keyword entered.. The working of search engines is not this simple. It involves incredibly detailed processes andmethodologies. There might be some differences in the working of different search engines.However, all of them perform three fundamental tasks includingcrawling the Web by followingall possible links from any Web page, extracting keywords from the collected Web pages and building an index, and allowing users to search for matching Web pages using the keywordssaved in the index.Search engines today are indexing and responding to billions of Web pages in a single day. Letus now look at how all these happen.Search engines use the following processes in its working: Web Crawling. Indexing. Searching.We will now study each of these operations in detail. Web crawling:

When you search for information by typing keywords in a search engine Websiteit gives you a list of related information. Prior to listing the related information, it has to find it.In order to retrieve information from the numerous Websites that exist on the WWW, a search engine utilises special software robots known as spiders. The spiders are simple programs thatscan the Web pages to create a list or index of words that are found on the Websites, and the process of creating a list or index of words by a spider is known as Web crawling. Indexing: After the spider program finishes the job of looking for information on the Web pages,the search engines have to store the information such that it is useful for the users. This is knownas indexing. An efficient indexing helps us to quickly find information on the Web.The two key components responsible for indexing or making the gathered data accessible tousers are as follows: The information that is stored with the data: Here, a search engine can store the word and theUniform Resource Locator (URL) of the Web page where the word was found. However, thisresult in limited use of the Web page as it will not inform the user if the word was used manytimes or only once. It will also not specify if the page comprises links to any other page, or if theword was an important phrase on the Web page. The technique in which the information is indexed: Here, a search engine stores the number of times the word has appeared on the Web page rather than storing only the word and the URL. A particular words value increases when it appears in the heading, sub heading or in the links.Considering this, a search engine assigns weight to every entry Searching: It refers to the process of querying a search engine. A query should have at least aminimum of one word. You can also have complex queries. Complex queries are built usingBoolean operators that help us to refine the search Types of search engine Now that you have learnt how a search engine works, let us now study the different types of search engines.The different types of search engines are: Crawler based search engines. Human powered directories. Hybrid or mixed search engines.We will now study more about these search engines. Crawler based search engines: In this type of search engines the spiders crawl through the Weband create a listing or index of words. Whenever a user enters a query or a keyword using asearch engine, the word is searched for against these listings or index. The index consists of acopy of all the Web pages that is found by the spider. Whenever a change is made to any of theWeb pages, the spider will update the changes in the index. This is possible as the spiders arealways crawling through the Web pages on a regular basis Human powered directories: I n t h i s t y p e o f s e a r c h e n g i n e t h e r e i s a d i r e c t o r y w h i c h g e t s information from short descriptions about the websites along with the address and title of theWeb pages that are submitted by the webmasters. These submissions are later reviewed by theeditors. The disadvantage of human powered directories is that it can take months to get your Website reviewed unless you take up a paid inclusion program. Hybrid or mixed search engine: It is a combination or mixture of crawler based search enginesand human powered directories. The basic idea behind a hybrid search engine is to provide theusers with a combination of

results including spidered results and directory results. Google andYahoo are today using hybrid search engines. Google calls this Universal Search. Importance of search engine friendly website You have now learnt about the different types of search engines. Let us now learn why a searchengine friendly Website is important.Search engine friendly refers to the design of a Website that includes images, videos, menus,c o n t e n t m a n a g e m e n t s ys t e m a n d v a r i o u s o t h e r e l e m e n t s t h a t h e l p a s e a r c h e n g i n e t o g e t t h e maximum information about the Website for the purpose of search engine exposure.A search engine friendly Website is important because, when your Website is search enginefriendly it is easy for visitors to find your Website. This could be done by listing your Websiteon top of all the other Websites in the list returned by a search engine. When your Website is ontop of the list it generally gains the attention of the visitors and thus will motivate them to visityour Website. Q.6 Explain Java web technologies with its types [10 Marks] Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntaxfrom C and C++, but it has fewer low-level facilities than either of them. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users.[10][11] Java Web Technologies The first web sites that hit the Internet served up static content through ordinary HTML documents; if you wanted to display a catalog of items that you were selling, you would have to build the HTML page completely from scratch. Updates to your catalog required you to make updates to your HTML documents. Someone had the revolutionary idea of building HTML documents programmatically. Thus was the inception of CGI scripts; CGI scripts started as C programs used to programmatically build HTML documents. Several technologies emerged including: Cold Fusion, Active Server Pages, Server-side JavaScript, and PHP. In 1997, Sun released the Servlet specification and then we were able to develop HTML dynamically in Java in a vastly simpler manner than other technologies that existed at that time. The Servlet specification defines an entity called a Servlet Container that maintains a mapping of Web requests to Servlets; when the container receives a request, it loads the Servlet into memory, initializes it, and then executes it. A Servlet, therefore, is a Java program that returns an HTML document: the HTML code is embedded inside the Servlet Java code and returned to the called by print() and println() method calls. Servlets were a great technology for the day, but there was still a problem: we had all of these great and easy to use HTML editors that simplified Web Development, but we were unable to use them.

Furthermore, a simple change to an HTML document, such as adding a comma or bolding a word, required that a Java developer edit the Servlet code to make the changes (again inside print() methods), recompile the Servlet, and then deploy the new version of the Servlet back to the Servlet container. Maintenance was a nightmare! Then in 1999, Sun released the JavaServer Pages (JSP) specification. JSP took the opposite approach to Servlets: instead of writing Java code to generate HTML, they would embed Java code inside HTML pages. JSP used special tags to delimit Java code and thus we were again able to edit them using HTML editors. Furthermore, the specification did not require JSP files to be compiled and the specification handled the deployment; when the Servlet Container received a request for the named JSP file, it translated it into Servlet code, compiled the code, and then loaded the generated Servlet into memory to handle the user's request. The Servlet specification already maintained the mechanism to cache Servlets in memory, so this translation, compilation, and loading operation occurred only on the JSP file's initial request. But we did not have a panacea yet. As Web Applications grew in complexity, JSP files became more and more complicated. JSP files needed to connect to databases and other external resources (such as legacy mainframes) resulting in a huge amount of Java code. JSP files now became difficult to maintain because they were convoluted with Java code, obscuring the HTML code; furthermore, business processes were difficult to maintain because they were directly embedded inside JSP files. Finally developers started looking back to an application model originally defined in the SmallTalk programming language: Model, View, Controller (MVC). The concept was to separate your business model into three components:

Model: represents the data in your application View: responsible for presenting the data (or models)

Controller: responsible for translating user actions performed on the view to changes to the model In its first manifestation is was referred to as the "Model 2" architecture and it divided web application components into the following logical categories:

Servlets: became the controller or the party responsible for executing business processes JavaBeans: became the model JSP: became the view or presentation layer

The process became: 1. The Servlet Container receives a user request and forwards it to a Servlet 2. The Servlet either directly or through other classes/technologies executes the business processes to handle the request 3. The Servlet obtains the results of the business processes and packages them inside JavaBeans 4. The JavaBeans are then forwarded to JSP files for presentation back to the caller And this is the basic model for Java web applications, as we know them today. There are several prebuilt web architectures for you to choose from, probably the most popular one is Jakarta Struts, or there are several books that will walk you through building a web architecture on your own. This week's introduction to Java Web Technologies will walk you through writing, compiling, deploying, and testing a Servlet. Next week we will look at JSP files, and in two weeks the Model 2 architecture.

Master of Business Administration - MBA Semester IV MI0041 Java and Web Design - 4 Credits Assignment - Set- 2 (60 Marks) Q.1 Explain the browser components and its features [10 Marks] Browser components Now let us learn the architecture of a Web browser with the help of reference architecture. This reference architecture is the basic architecture for Web browsers and helps you to easily understand the various components that exist in the Web browser.

Figure 1.1: Main Components of Browser[1] As shown in the figure 1.1 the Web browser consists of seven main components, each having a specific task to perform and they are: User interface: It consists of an address bar where you can enter the URL, bookmarkmenu to save the links of your favourite Web pages, back/forward button to navigate to the previous Web page/next Web page, and so on. Browser engine: It is the interface through which you can ask questions to the browser and manipulate the rendering engine. It also sets the layout of a Web page formatted with HTML tags within a browser. Rendering engine: It is displays the content you had requested, after obtaining it from the respective Web server. Networking: It is used for calling the network for example, raising an HTTP request for a URL connection through the server. Display backend: It provides drawing tools, user interface widgets, and fonts that help to display text and graphics. Javascript interpreter: It is used to parse and execute the codes of written using the Java script (refer Unit 6). Data storage: This enables the browser to save all the data on the hard disk and acts as the database of the browser. Features of browser Now that we have learnt about the components of a browser, let us now study some of the most important features of a browser. The figure 1.2 shows the screen shot of the Microsofts Internet Explorer Web browser. The arrows point to the features that are available on the Web browser along with the name of the corresponding feature mentioned at the other end of the arrow.

Figure 1.2: Web Browser and its Features

From the figure 1.2 you can see some of the features that are present as icons or buttons on a Web browser. If you do not find it as a button you can find the same in one of the menus provided in the menu bar. Let us now briefly discuss the features that are mentioned in the figure 1.2: Address field: This is the area on the browser window where you enter the Web page address or URL. At the right end of this area, there is a small arrow pointing towards the menu bar, when you click this arrow you will view a list of some of the Websites that you have visited recently. When you click on these URLs you will view the respective Website or else you can directly enter the address in the address field. After you enter the address you can either press Enter or click on the Go button (which is present next to the downward facing arrow button in some browsers). Back and forward buttons: The back button is used to go back to the previous page that you have opened in a particular browser window. The forward button allows you to view pages that you have previously viewed in that browser window. In some browsers, there is a small arrow pointing towards the menu bar arrow right next to these buttons, when you click this arrow you will see the list of Websites that you have visited after opening the browser window. Home button: When you click this button you will be able to view the page that you have set as home page. A home page is a default page that opens when you open the browser window. Menu bar: A menu bar is a part of each browser window, it contains menus like File, Edit, View, Favourites or Bookmarks, Tools and Help. Refresh or reload: When you click the refresh or reload button, the page is updated. For example, if you think that the contents of a browser window may have changed since the last time you viewed it, you can click this button to update the page. Security indicators: At the left corner of the window, a lock icon appears when you use a browser and this is called padlock. If the padlock is in a lock position then you can say that your server connection is secure, i.e. the data being sent and received by the server is encrypted. This indicates that nobody else can access this data. There is another way to find out whether your browser is secure or not and that is done by looking at the URL. If the URL of your Website begins with https:// for example, you enter an address www.gofind.com in the address field and press enter or click Go then automatically the address changes to https://www.gofind.com indicating that your browser connection is secure. Status bar: This is a bar at the bottom of the browser window which indicates the URL of the Web page currently being loaded into the browser window. It also displays the URL of the link on which the cursor of your mouse is placed. While loading, the Web page shows a progress indicator which shows how much percentage of a file has been downloaded. Stop button: This button is used to stop the browser from loading the Web page on to the browsing window Q. 2 Describe in detail the building of webpage. [10 Marks] Building a Web Page We understood the basic concepts of HTML. Now let us study how to organise the content on aWeb page. Building a Web page involves great planning and design. Before you design the Web p a g e i t is very important to plan the structure of the Web page and also decide the k i n d o f content that you insert in to the Web page.The usability of the page will make the Website reach out to large a group of audience. Only if the page is user friendly it can retain its users. Therefore, you need to design the Web page withsimple and reliable interfaces and navigations so that it can be easily understood and used by theaudience. These interfaces comprises of images, graphics, coloured texts and so on. You must provide hyperlinks to related content so that the Web page users can navigate to other Web pagesto get more information about the content.Once you have gathered, organised, and structure the next part is deciding upon the

placement of the content on the Web page. A plan that describes how to organise the various elements of c o n t e n t l i k e t e x t , g r a p h i c s a n d s o o n , o n t h e W e b p a g e i s k n o w n a s t h e W e b l a yo u t . W h i l e designing the Web layout, you first need to decide the position and placement of every elementof the content. A good designer will not place and position the element randomly on the Web page. Therefore, you need to think about the significance of each element, how it is related to theobjectives of the Web page, whether it fits with other elements around it and so on and thendecide the positioning and placement of the elementsSome of the basic aspects of Web layout that you need to keep in mind while designing a Web page are: Space and white space: Try to use the entire space available on the Web page. However, makesure you do not overcrowd the page with too much information. You need to keep the screenresolution in mind so that your text does not look too small or too large. You can use colours todefine spaces.. Images and graphics: Images and graphics are a major part of your Web layout. You need tomake sure that you check the image size and position before you put it on the Web page. Since,images have large impact on the audience than the text. Text width: Often referred to as scan length this defines the number of words you can displayon one line. Most designers prefer to have seven to eleven words in a line just to make sure thatthe user is able to read it without any difficult. Since, most people are not comfortable readinglengthy sentences We have learnt how to create a Web page and include content in our Web page. Let us now learnhow to format our Web page.The formatting elements help you to organise and format the content on your Web page. Thismakes your Web pages more attractive and allows you to present the information as you wish.Let us now study some of text formatting elements available in html and format our Web page. Heading elements You can use these elements to format the headings in your Web page. The font s i z e s o f t h e heading elements vary form size one to six. For example, if you want to display a main headingo f a W e b p a g e M y P a g e w i t h t h e f o n t s i z e o f s i x t h e n t h e c o m m a n d l i n e i s , < h 1 > M y Page</h1>. If you want to display the same text Web Page with the font size one then, thecommand line is <h6>My Page</h6>. The font size can be specified precisely in pixels for eachheader tag using Cascading Style Sheets (refer Unit 4). Font styling elements The HTML provides you a number of elements that allow you to modify the styles of the font.Let us now discuss some of the elements you can use to modify the styles and they are: Bold text: To make the text appear in bold on your Web page you can start that part of the textor word with the tag <b> and close the text with "</b>". The part of the text within these tagsappears bold on your Web page Underlining the text: To underline the text on your Web page, you can start that part of the textor the word that you want to underline with the tag <u> and close the text with "</u>". The partof the text within these tags appears underlined on your Web page Text positioning The text positioning elements enable you to align the text on your Web page. Some of the mostimportant elements are:

Paragraph: You can create a paragraph on your Web page by entering the text within the <p>and </p> tags. You can use the font styling element inside the paragraph element and this iscalled nesting. The syntax for this is:<p>Paragraph text</p> Font appearance The font appearance includes the colour, size and type of the font. Using the attributes fontcolour, font size and font type you can assign different font colour, size and type to the fonts thatyou want to display on your Web page Q.3 How to use forms? Explain with an example [10 Marks] Using a Form We have learnt about multimedia files and how to insert multimedia files on the Web page. Letus now discuss about HTML forms. You might have signed up to Gmail, Yahoo! or any of theother online communities. When you visit the page, it asks you to fill and submit an online form.We can use the HTML tags to create such forms on Web page. Usually, forms contain inputelements like text fields, checkboxes, radio-buttons, submit buttons and so on. Text fields: This is a single line input filed where you can enter the text. The example codeshows how to create it using the tag <input type="text"/>. Password field: This field is similar to text field and the only difference is that you can view thetext you enter in the text field. However, in password field you cannot see the text that you enter,for every character that you enter you see either an asterisks (*) or dot (.). You can use the sametag that you used to create text field except that the value that you pass to the attribute "type" will be "password". This signifies that the field is a password field. Using the attribute "name" youcan define a variable to store the password that you enter Radio buttons: This button allows you to select only one of the items from the given list. For example, for a question asked in a form they provide four answers out of which only one answer will be correct and you have to choose only one out of the four. In such cases, you can use radio button. Checkboxes: The code for checkboxes is similar to the radio buttons. The only difference isthe value that we pass to the attribute "type". For selecting the checkbox element we pass the value "checkbox" to the attribute "type". Another important difference which we need to know isthat in checkbox you can select any number of items. Submit button: This button is used to send form data from the Web page to the Web server.This button is created on the Web page using the example code shown below:You can see from the example code shown above that there are few new attributes which wehave defined in the opening <form>, "action" and "method". The "action" attribute specifies theaddress or URL to which the form has to be submitted when you click the submit button. Whenyou pass the value "get" to the attribute "method" then, the form data that you send to the URLspecified in the attribute "action" is sent as an attachment to the URL. This means it will not besent separately but as a part of the URL page. Therefore, the amount of data that you can send islimited. It is used to send short forms with one or two input fields such as text fields, radio buttons, checkboxes and so on. Since, the data is simply attached to the URL and other users onthe Web can easily access it. There is another way of sending the data that is by passing the value"post" to the attribute "method". You can

send any number of data or input elements such as textfields, radio buttons, checkboxes and so on using the post method. Form data sent using thepost method can also be encrypted and sent securely using the HTTPS protocol.The output of the above code is as shown below, . Q.4 How do you handle exceptions in Java [10 Marks] An exception is a problem that arises during the execution of a program. An exception can occur for many different reasons, including the following:

A user has entered invalid data. A file that needs to be opened cannot be found. A network connection has been lost in the middle of communications, or the JVM has run out of memory.

Some of these exceptions are caused by user error, others by programmer error, and others by physical resources that have failed in some manner. To understand how exception handling works in Java, you need to understand the three categories of exceptions:

Checked exceptions: A checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation. Runtime exceptions: A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compliation. Errors: These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation.

Exception Hierarchy: All exception classes are subtypes of the java.lang.Exception class. The exception class is a subclass of the Throwable class. Other than the exception class there is another subclass called Error which is derived from the Throwable class. Errors are not normally trapped form the Java programs. These conditions normally happen in case of severe failures, which are not handled by the java programs. Errors are generated to indicate errors generated by the runtime environment. Example : JVM is out of Memory. Normally programs cannot recover from errors. The Exception class has two main subclasses : IOException class and RuntimeException Class.

Here is a list of most common checked and unchecked Java's Built-in Exceptions. Exceptions Methods: Following is the list of important medthods available in the Throwable class. SN 1 Methods with Description public String getMessage() Returns a detailed message about the exception that has occurred. This message is initialized in the Throwable constructor. public Throwable getCause() Returns the cause of the exception as represented by a Throwable object. public String toString() Returns the name of the class concatenated with the result of getMessage() public void printStackTrace() Prints the result of toString() along with the stack trace to System.err, the error output stream. public StackTraceElement [] getStackTrace() Returns an array containing each element on the stack trace. The element at index 0 represents the top of the call stack, and the last element in the array represents the method at the bottom of the call stack. public Throwable fillInStackTrace() Fills the stack trace of this Throwable object with the current stack trace, adding to any previous information in the stack trace.

2 3 4 5

Catching Exceptions: A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following:

try { //Protected code }catch(ExceptionName e1) { //Catch block } A catch statement involves declaring the type of exception you are trying to catch. If an exception occurs in protected code, the catch block (or blocks) that follows the try is checked. If the type of exception that occurred is listed in a catch block, the exception is passed to the catch block much as an argument is passed into a method parameter. Example: The following is an array is declared with 2 elements. Then the code tries to access the 3rd element of the array which throws an exception. // File Name : ExcepTest.java import java.io.*; public class ExcepTest{ public static void main(String args[]){ try{ int a[] = new int[2]; System.out.println("Access element three :" + a[3]); }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Exception thrown :" + e); } System.out.println("Out of the block"); } } This would produce following result:

Q.5 Write a small snippet in which the program uses POST method to accept the keywords to accomplish the task. Also suggest the alternative method to perform this task and its benefits [10 Marks] answer: The working of servlets begins when the client or the users Web browser passes arequest to the server. The browser uses the HTTP protocol GET method or POST method to passa request to the server. For example, we can invoke a servlet when we click on the submit buttonof a form, or by clicking on a hyperlink that is present in a Web page. Once the servlet processesthe request, the client or the Web browser gets the output in the form of a HTML page. We havenoted that the request made by the client or the Web browser consists of few components.

Q.6 List the benefits and drawbacks of Lamp stack [10 Marks] Benefits and drawbacks of LAMP stack Now that you have understood how the LAMP stack originated, we will now discuss the benefitsof LAMP stack that has made it popular.Even though there are various commercially available software packages that provide variousfeatures in Web development, many Web applications today, are using the LAMP stack. This is because of the various benefits it provides. The benefits of LAMP stack are as follows: It is open source software package and thus can be got free of cost. This helps organisations tod e v e l o p W e b a p p l i c a t i o n s w i t h o u t s p e n d i n g h e f t y a m o u n t s f o r i t s l i c e n s i n g . E v e n t h o u g h Microsoft offers the ASP (Active Server Pages) extensions free of cost, they charge you for their Operating System, database servers, and Integrated Development Environment (IDE). However,sometimes companies may have to pay for customer support for the open source products thatthey purchase from vendors It can be installed on a wide range of platforms. We can use Windows instead of Linux if weare working on Windows platform, or use IIS instead of Apache Web server. This helps us toadapt to our companies current environments by utilising the existing infrastructure. It provides a greater support when compared to other commercially available software. This is because the components of LAMP stack are open source and thus we can find support from theactual developers who have worked on the project, and also from its community. It is possible for us to find various modules that can be reused. These modules are built by acommunity of developers who publish the modules developed by them. This saves time andresults in rapid development of Web applications. It facilitates us with an efficient hardware support such as Linux that can run on almost allservers. This is possible as it facilitates the administrator with the choice of running only what isrequired to perform a particular job. It offers greater performance as we use Linux. When compared to Windows, Linux scales highin performance, memory management, and stability. It is possible for us to find constant updates and improvements for the LAMP stack. As youk n o w , w e c a n f i n d d e v e l o p e r s a n d s u p p o r t c o m m u n i t i e s t h a t u p d a t e n e w f e a t u r e s a n d enhancements constantly.Despite of the above mentioned benefits LAMP stack has a few drawbacks. The drawbacks of LAMP stack are as follows: T h e m a i n disadvantages of LAMP stack is in updating the applications. This is b e c a u s e , whenever you have a new version released, we have to follow the same procedure that is used ininstalling the applications, to update the changes. There could be confusion as to where the application is installed as the application files are not placed in the file system in a standard way. One more disadvantage is that it is difficult to find people who are good and q u a l i f i e d i n developing Web applications on LAMP platform. Hence, organisations fear to switch to LAMP

You might also like