PATEL GROUP OF INSTITUTIONS

Size: px
Start display at page:

Download "PATEL GROUP OF INSTITUTIONS"

Transcription

1 Q1) What is JSP? Explain its role in the development of web sites. Ans: JSP is an existing new technology that provides powerful and efficient creation of dynamic contents. It allows static web content to be mixed with java code. It is a technology using server-side scripting that is actually translated into servlets and compiled before they are run. Role of JSP in the development of websites: In today s environment dynamic content is critical to the success of any web site. There are a number of technologies available for incorporating the dynamic contents In a site. But most of these technologies hhave some problem. Servlets offer several improvements over other server extension methods. But still suffer from a lack of presentation and business logic separation. So the java community worked to define a standard for a servlet based server pages environment. JSP separates the presentation layer(i.e. web interface logic) from the business logic(i.e. back end content generation logic) so the web designer and web developers can work on the same web page without getting in each other s way.. Q2) Explain various scripting elements used in JSP. OR Q3) What is JSP? Explain Scriptlets in JSP. Ans: JSP is an exciting new technology that provides powerful and efficient creation of dynamic contents. It is a presentation layer technology that allow static web content to be mixed with java code.jsp allows the use of standard HTML, but adds the power and flexiblity of the java programming language. JSP does not modify static data. JSP is an extremly powerful choice for web devlopmen. It is a technology using server side scripting that is actually translataed into servlets and compiled before they are run. JSP uses the <% tag to note the start of JSP section, and the %> tag to note the end of a JSP section. JSP will interpret anything within these tags as a special section.these tag is known as scriptlets. Scripting Elements: we will understand different types of tags or scripting elements used in JSP. A JSP page contains HTML.( or other text based format such as XML) mixed with elements of the JSP syntax. There are five basic types of elements, as well as a special format for comments. These are 1. Scriptlets: The Scriptlet element allows java Code to be embedded directly into a JSP page. JSP Synatx: <% code %> XML Synatax: : <jsp:scriptlet>code</jsp:scriptlet> Scriptlets are the most common JSP syntax elements. As you have studied above, a scriptlet is a portion of regular java code embedded in the JSP content within Developed by: Prof. ADNAN AHMAD PATHAN Page 1

2 < %...%> tags. The java code in scriptlets is executed when the user ask for the page. Scriptlets can be used to do absolutely anything the java language supports, but some of their more common tasks are: a. Executing logic on the server side; for example accessing a database. b. Implementing conditional HTML by posing a condition on the execution of portion of the page. c. Looping over JSP fragments, enabling operations such as populating a table with a dynamic content. Example: <html> <head> <title>scriptlet </title> </head> <body> <h2> <%@ page import="java.util.*"%> <% Date d = new Date(); out.println("today is : "+d); %> </h2> </body> </html> 2. Expression: An expression element is a java language expression whose value is evaluated and returned as string to the page. JSP Synatx: <% =code %> XML Synatax: : <jsp:expression>code</jsp:expression> Printing the output of a java fragment is one of the most common tasks utilized in JSP pages. For this purpose we can use the out.println() method. But having several out.println() method tends to be cumbersome. Realizing this author of the JSP specification created the expression elements. The expression begins with the standard JSP start tag followed by an equals sign (< %=). Example: <Html> <Title> Current Date</title> </head> <body color=#ffffff> The current date is <%=new java.util.date()%> //Expression element </body> </Html> Developed by: Prof. ADNAN AHMAD PATHAN Page 2

3 3. Declaration: A declaration element is used to declare method and variables that are initialized with the page. JSP Synatx: <%! code %> XML Synatax: : < jsp:declaration>code</jsp:declaration> The third type of Scripting element is the Declaration element. The purpose of a declaration element is to initialize variable and method and make them available to other declaration, Scriptlets, and expression. Variables and methods created within declaration elements are effectively global. The syntax of the declaration element begin with the standard JSP open tag followed by an exclamation point (< %!). The declaration element must be a complex java statement. it ends with a semicolon, just as the scriptlet element does. Example: <%! Private ClasJsp Obj; Public void jspinit() public void jspdestroy() %> //methods and variable declaration 4. Directives: Directive elements contain global information that is applicable to the whole page. JSP Synatx: <%@ code %> Example: <%@ page import="java.util.*"%> 5. Action: Action elements provide information for the translation phase of the JSP page. And consist of a set of standard, built in methods. Custom action can also be created in the form of custom tags. This is new feature of the JSP 1.1 specification The first three elements -----Scriptlets, Expression, and Declaration ----are collectively called scripting elements.... Developed by: Prof. ADNAN AHMAD PATHAN Page 3

4 Q4) What are various implicit objects used with JSP? OR Q5) What are predefined variable in JSP? Ans: PREDEFINED VARIABLES: To simplify code in JSP expression and scriptlets, Servlet also creates several objects to be used by the JSP engine; these are sometimes called implicit objects (or predefined variables). Many of these objects are called directly without being explicitly declared. These objects are: 1. The out Object 2. The request Object 3. The response Object 4. The page Context Object 5. The session Object 6. The config Object 7. The application Object 8. The page Object 9. The exception Object The out Object: The major function of JSP is to describe data being sent to an output stream in response to a client request. This output stream is exposed to the JSP author through the implicit out object. The out object is an instantiation of a javax.servlet.jsp.jspwriter object. The Request Object: Each time a client request a page of JSP engine creates a new object to represent the request. This new object is an instance of javax.serblet.http.httpservletrequest and is given parameters describing the request.this object is exposed to the JSP author through the request object. The Response Object: Just as the server creates the request object it also creates an object to represent the response to the client. the object is an instance of javax.servlet.http.httpservletresponse and is exposed to the JSP author as the response object. The page Context Object: The Page Context Object is used to represent the entire JSP page. It is intended as a means to access information about the page while avoiding most of the implementation details. The Application Object The application object is direct wrapper around the ServletContext Object for the generated servlet. It has the same methods and interfaces that the ServletContext object does in programming Java Servlets. This object is a representation of the JSP page through its entire lifecycle. The Config Object: The config object is an instantiation of javax.servlet.servletconfig.this object is a direct wrapper around the ServletConfig object for the generated servlet. Developed by: Prof. ADNAN AHMAD PATHAN Page 4

5 The Page Object: This object is an actual reference to the instance of the page. It can be thought of as an object that represents the entire JSP page. The Exception Object: The error handling method utilizes this object. It is available only when the previous JSP page throws an uncaught exception and the %> tag was used. The Session Object: A session of web browsing is a period of time during which particular person sitting a particular machine, view a number of different page of web and then call it quit. Session are used to store information between http request for a particular user or single user when user starts browsing a web site all the information for that particular users has to be stored. Q6) What do you understand by JSP Action? OR Q7) what is the different between <jsp:include page= > and <%@ include file=.>? OR Q8) Write a note on jsp:fallback and jsp:param Element. Ans: JSP has three main capabilities for including external piece into a jsp document. 1. JSP:include action This include generated a page, not JSP code. It can not access environment of main page in include code. Jsp:include action includes files at the time the client request and thus does not require you to update the main file when an included file changes. Jsp:include element has two required attributes Page: It refers to a relative URL referecing the file to be included Flush: This must have the value true. Syntax: <jsp:include page= relative URL flush= true /> 2. Include directive Include directives include dynamic page. i.e. JSP code, it is powerful, but poses maintenance challenges. You can include a file with JSP at the page translation time. In this case file will be included in the main JSP document at the time the document is translated into a servlet. In include directive if the include file changes, all the JSP files that use it need to be updated. Syntax: <%@ include file= relative URL %> 3. Jsp:plugin action This inserts applet into JSP that use the java plugin. It increase client side role in dialog. Developed by: Prof. ADNAN AHMAD PATHAN Page 5

6 Jsp:plugin has four attributes : type,code,width and height. You supply value of applet of type attribute and use the other three attribute in exactly same way as with the APPLET element, with two exceptions, i.e. attribute names are case sensitive and single or double quotes are always required around the attribute value. Syntax: <APPLET CODE= MYApplet.class WIDTH=400 HEIGHT=200> </APPLET> You could replace this code with <jsp:plugin type= applet code= MyApplet.class width= 400 height= 200 > </jsp:plugin> The jsp:param and jsp:params Elements: The jsp:param element is used with jsp:plugin in a manner similar to the way that PARAM is used with APPLET. There are two main differences between jsp:param and param with applet. First jsp:param follows XML syntax, attribute names must be lower case and values must be enclosed single or double quotes. Second all jsp:param entries must be enclosed within a jsp:params element. Syntax: <APPLET CODE= MYApplet.class WIDTH=400 HEIGHT=200> <PARAM NAME= PARAM1 VALUE= VALUE1 > </APPLET> You could replace this code with <jsp:plugin type= applet code= MyApplet.class width= 400 height= 200 > <jsp:params> <jsp:param name= PARAM1 value= VALUE1 /> </jsp:params></jsp:plugin> Jsp:fallback Element: The jsp:fallback element provides alternative text to browsers that do not support OBJECT or EMBED. You use this element in almost the same way as you would use alternative text placed within an APPLET element. Synatx: <APPLET CODE= MYApplet.class WIDTH=400 HEIGHT=200> <B>Error: this example requires Java</B> </APPLET> You could replace this code with <jsp:plugin type= applet code= MyApplet.class width= 400 height= 200 > <jsp:fallback> <B>Error: this example requires Java</B> </jsp:fallback> </jsp:plugin>.. Developed by: Prof. ADNAN AHMAD PATHAN Page 6

7 Q9) What is the different between <jsp:forward page= > and response.sendredirect(url)?or Q10) What is the different between Forwarding Request from JSP and Forwarding request from Servlet? Ans: Forwarding Requests from JSP pages: The most common request forwarding scenario is that the request first comes to a servlet and the servlet forwards the request to a JSP page. The reason is a servlet usually handles the original request and destination page is usually JSP document. But it is also possible the destination page to be servlet and request forward from JSP page to servlet or elsewhere.for this purpose JSP use jsp:forward action. Syntax: <jsp:forward page= relative URL /> <% String destination; If(MATH.random()>.5) Destination= /example/page1.jsp Else Destination= /example/page2.jsp %> <jsp:forward page= <%=destination%> /> Forwarding Requests from Servlet: The key to letting servlets forward requests or include external content is to use a requestdispatcher. You obtain a RequestDispatcher by calling the getrequestdispatcher method of ServletContext, suuplying a URL relative to the server root. Once you have RequestDispatcher, you use forward to completely transfer control to the associated URL and use include to output the associated URL s content. In both case you supply the HttpServletResponse and HttpServletRequest as arguments. HttpServletResponse class also provides sendredirect() method to forward request into another page. Syntax: String url= /examples/jsp/page1.jsp RequestDispatcher d=getservletcontext().getrequestdispatcher(url); d.forward(request,response); OR Response.sendRedirect( Relative URL ); Developed by: Prof. ADNAN AHMAD PATHAN Page 7

8 Q11) Give the names of JSP directive. Briefly explain all attributes of JSP page directive. Ans: Directives: Directive elements contain global information that is applicable to the whole page. JSP Synatx: code %> Types of directive tag: 1. Include directive Include directives include dynamic page. i.e. JSP code, it is powerful, but poses maintenance challenges. You can include a file with JSP at the page translation time. In this case file will be included in the main JSP document at the time the document is translated into a servlet. In include directive if the include file changes, all the JSP files that use it need to be updated. Syntax: <%@ include file= relative URL %> 2. Page directive The he page directive applies to an entire JSP file and any of its static include files, which together are called a translation unit. Syntax: <%@ page attributename="values" %> <%@ page import= java.util.* %> 3. Taglib directive Once you have a tag handler implementation and a TLD. You are ready to write a JSP file that makes use of the tag. Somewhere in the JSP page you need to place the taglib directive. Syntax: <%@ taglib uri=. Prefix= %> The required uri attribute can be either an absolute or relative URL referring to a TLD file. The required prefix attribute specifies a prefix to use in front of any tag name defined in the TLD of this taglib declaration The list of the JSP page directive tag attributes is: Language, extends, import, session, info, errorpage, contenttype, buffer, autoflush, isthreadsafe IsErrorPage.. Q12) What is importance of JavaBeans in JSP? Explain important JSP actions to build and manipulate JavaBean component along with all its attributes. OR Q13) What is JavaBeans? Explain elements of JavaBean. Ans: JavaBeans are used to inserting dynamic content in JSP pages. Develop separate utility classes structured as beans. Use jsp:usebean, jsp:getproperty, and jsp:setproperty to invoke the code. Developed by: Prof. ADNAN AHMAD PATHAN Page 8

9 Many types of benefit provide a separate Java classes instead of embedding large amounts of code directly in JSP pages. Separate classes are easier to write, compile, test, debug, and reuse. What do beans provide that other classes do not? Beans are merely regular java classes that follow some simple conventions defined by the JavaBeans. Beans extend no particular class. Beans do not use package. Beans do not use particular interface. Using beans, other program can automatically discover information about classes. JavaBeans provides three advantages: 1. No Java syntax: the programmer can manipulate java object using only XML syntax: no parentheses, semicolons, or curly braces by using beans. 2. Simpler object sharing: when you use the JSP bean, you can much more easily share objects among multiple pages or between requests. 3. Convenient correspondence between request parameters and object properties: the jsp bean constructs simplify the process of reading request parameters, converting from strings and putting the results inside objects. Beans class has three simple points : 1. A bean class must have a zero argument(default constructor. 2. A bean class should have no public instance variable. 3. Persistence values should be accessed through methods called getxx and setxx. Using Beans in JSP page: You use three main constructs to build and manipulate JavaBeans components in JSP pages: jsp:usebean. In the simplest case, this element builds a new bean it is normally used as follows. <jsp:usebean id= beanname class= package.class /> jsp:getproperty. This element reads and outputs the value of a bean property. This elements used as follows. <jsp:getproperty name= beanname property= propertyname /> Jsp:setproperty. This element modifies a bean property. It is used as follows. <jsp:setproperty name= beanname property= propertyname value= propertyvalue />.. Q14) Why MVC framework is required to build complex applications? Briefly explain the role of RequestDispatcher in MVC. OR Q15) What is MVC? Explain implementing MVC with ReqquestDispatcher. Ans: MVC is used to inserting dynamic content in JSP pages. The servlet handles to original request, look up data, and store results in beans. Then servlet forward this beans to jsp page to present result. Jsp page uses beans. MVC Architecture or Approach: MVC (MODEL VIEW CONTROLLER) or (MODEL 2 ARCHITECTURE) The original request is handled by a servlet. The servlet invokes business logic and data access code and creates beans to store the data / to represent the results. So the bean is model. Then the servlet decides which JSP page is appropriate to present those particular result and forward request to jsp page. So the JSP page is the view. The servlet decides what business logic code applies and which JSP page should present the results. So the servlet is the controller. Developed by: Prof. ADNAN AHMAD PATHAN Page 9

10 MVC Frameworks: the key motivation behind the MVC approach is the desire to separate the code that creates and manipulates the data from the code that presents the data.the basic tools needed to implement this presentation layer separation are standard in the servlet API. However in very complex applications a more elaborate MVC framework is sometimes beneficial. The most popular of these frameworks is Apache Struts. Implementing MVC with RequestDispatcher: the most important point about MVC is the idea of separating the business logic and data access layers from the presentation layer. The syntax is quite simple. Here following steps are include. 1. Defines beans to represent the data: as you know beans are java object. First step define beans to represent the results that will be presented to the user. 2. Use a servlet to handle request: the servlet reads request parameters. 3. Populate the beans: the servlet invokes business logic or data access code to obtain the results. The results are placed in the beans. Example: Storing data into session: ValueObject value=new ValueObject(.); HttpSession session=request.getsession(); Session.setAttribute( key,value); Next the servlet would forward to a jsp page that uses the following to retrieve the data. <jsp:usebean id= key type= package.valueobject scope= session /> Storing data into request ValueObject value=new ValueObject(.); request.setattribute( key,value); <jsp:usebean id= key type= package.valueobject scope= request /> Storing data into servletcontext ValueObject value=new ValueObject(.); getservletcontext()..setattribute( key,value); <jsp:usebean id= key type= package.valueobject scope= application /> 4. Store the bean in the request,session or servlet context: the servlet calls setattribute on the request, session or servlet context objects to store a reference to the beans that represent the results of the request. 5. Forward the request to a JSP page: the servlet determines which JSP page is appropriate to the situation and uses the forward method of RequestDispatcher to transfer control to that page. Example: RequestDispatcher d=request.getrequestdispatcher(address); d.forward(request,response); 6. Extract the data from the beans: the jsp page accesses beans with jsp:usebean and then use jsp:getproperty to output the bean properties. The jsp pages does not create or modify the bean. It merely extracts and displays data that the servlet created. Example: <jsp:usebean id= key type= package.classname scope= session /> <jsp:getproperty name= key propert= propertyname />. Developed by: Prof. ADNAN AHMAD PATHAN Page 10

11 Q16) What is the JSP Expression Language? Explain elements supported by EL. OR Q17) What is the Scoped Variable? How to EL access Scoped Variables? OR Q18) What is Expression Language? Explain operator of Expression Language. Ans: Use the JSP Expression Language(JSP EL): The one inconvenient part about this approach is the presenting the results in the JSP page. You normally use jsp:usebean and jsp:getproperty but these elements only supports access to simple bean property. If the property is a collection of another bean or subproperty requires you to use complex java syntax. The jsp 2.0 expression language lets you simplify the presentation layer by replacing hard to maintain java scripting elements or jsp:usebean and jsp:getproperty elements with short and readable entries of the following form. $expression JSP EL use shorthand syntax to access and output object properties. Usually used in conjuction with beans and MVC. The expression language supports the following capabilities. 1. Concise access to stored object: To output scoped variable named saleitem, you use $saleitem. 2. Shorthand notation for bean properties: To output the companyname property of scoped variable company. You use $company.companyname. To access the firstname property of the president property of scoped variable named company. You use $company.president.firstname. 3. Simple access to collection elements: To acces an element of an arrayt, List or Map. You use $variable[index or key]. 4. Succinct access to request parameters, cookies and other request data: To access the standard types of request data, you can use on of several predefined implicit objects. 5. A small but useful set of simple operators: To manipulate objects within EL expression, you can use any of several arithmetic,relational,logic or empty testing operators. 6. Conditional output: To choose among output option you do not have to resort to java scripting elements, instead you can use $test? option1 : option2. 7. Automatic type conversion:the expression language removes the need for most typecast and for much of the code that parses strings as numbers. 8. Empty values instead of error messages: In most cases, missing values or NullPointerExceptions result in empty strings not thrown exceptions. Accessing Scoped Variables: the servlet invoke code that creates the data then uses RequestDispatcher.forward or response.sendredirect to transfer control to the appropriate JSP page. The JSP page to access the data the servlet needs to use setattribute to store the data in one of the standard locations: the HttpSession,HttpServletRequest and ServletContext. The objects in these locations are known as Scoped Variables and the expression language has a quick and easy way to access them. You can also have scoped variables stored in the PageContext object but this is much less useful because the servlet and the JSP page do not share PageContext objects. To output a scoped variable you simply use its anme in an expression language element. For example, $name is equivalent <%= pagecontext.findattribute( name ) %> is equivalent <jsp:usebean id= name type= package.class scope= > <%= name %> Developed by: Prof. ADNAN AHMAD PATHAN Page 11

12 Using Expression Language Operators: Use the expression language operators for simple tasks oriented toward presentation logic(deciding how to present the data). Avoid using the operators for business logic(creating and processing the data). Instead put business logic in regular java classes and invoke the code from the servlet that starts the MVC process. The following types of operators are available. 1. Arithmetic Operators: +, -,*,/ and div % and mod 2. Relational operators == and eq!= and ne < and lt, > and gt, <= and le, >= and ge 3. Logical operators &&,and,,ot,!,not 4. Empty operator This operator returns true if its argument is null, an empty string, an empty array, an empty Map or an empty collection. Otherwise it returns false. Q19) Explain Tag Library Components in detail. OR Q20) What is a custom tags in JSP? What are the components that make up a tag library in JSP? Ans: A custom tag is a user defined JSP language element. Custom JSP tags are also interpreted by a program but unlike HTML, JSP tags are interpreted on the server side not client side. The program that interprets custom JSP tags is the runtime engine in the application server as Tomcat,JRun etc. When a JSP page containing custom tag is translated into a servlet, The tag is converted to operations on an object called tag handler. The custom tag is used to generating dynamic content inside the JSP page. Tag Library Components: To use custom tags, you need to define three separate components: 1. The tag handler class that defines the tag s behavior. 2. The TLD file that maps the XML element names to the tag implementations 3. The JSP file that uses the tag library The tag handler class: When define a new tag your first task is to define a Java class that tells the system what to do when it sees the tag. This class must implement the SimpleTag API interface. In practice you extend SimpleTagSupport class, which implements the SimpleTag interface and access some of its methods. The SimpleTag interface and SimpleTagSupport class are reside in the javax.servlet.tagext package. The code that does actual work of the tag goes inside the dotag method.usually, this code outputs content to the JSP page by invoking the print method of the JspWriter class. To obtain an instance of JspWriter class you call getjspcontext().getout() inside the dotag method. The dotag() methos is called at request time. The Tag library Descriptor File: Once you have defined a tag handler, your next task is to identify this class to the server and to associate it with a particular XML tag name. This task is accomplished by means of a TLD file in XML format. This file contains some fixed information such as description, name, tag class and body content. Developed by: Prof. ADNAN AHMAD PATHAN Page 12

13 Description: this optional element allows the tag developer to document the purpose of the custom tag. Name: this requires element defines the name of the tag as it will be referred to by the JSP page. Tag-class: this require element identifies the fully qualified name of the implementing tag handler class. Body-content: This required element tells the container how to treat the content between the beginning and ending of the tag. The value that appears here can be either empty, scriptless. The value of empty means that no content is allowed to appears in the body of tag. This means the declared tag can only appear following form: <prefix:tag/> or <prefix:tag></prefix:tag> The JSP File: Once you have a tag handler implementation and a TLD. You are ready to write a JSP file that makes use of the tag. Somewhere in the JSP page you need to place the taglib directive. This directive has the following form: <%@ taglib uri=. Prefix= %> The required uri attribute can be either an absolute or relative URL referring to a TLD file. The required prefix attribute specifies a prefix to use in front of any tag name defined in the TLD of this taglib declaration. For example, if the TLD file defines a tag named tag1 and the prefix attribute has a value of test, then the jsp page would need to refer to the tag as test:tag1. Syntax: <test:tag1>arbitrary JSP</test:tag1> or <test:tag1/>.. Q21) Explain all tags of JSTL with its all attributes. OR Q22) Explain plugin tags of JSP standard Tag Library. Ans: C:out Tag=> The c:out tag is very similar to jsp scripting expression like <%=.. %> and standard JSP EL use like $.. but it has many advantages. Unlike the JSP scripting, it is a regular tag. So it makes the HTML look cleaner. The title and heading of the page use the c:out tagto output special characters. <c:out value= hello /> C:forEach and c:fortokens=> the c:foreach tag provides basic iteration accepting many difference collection types. It can also function as a counter based for loop specifying a begin,end and a step index. It used var attribute. The c:fortokens tag functions much like c:foreach except it is designed to iterate over a string of tokens separated by delimiters. <c:foreach var = i begin= 1 end= 10 step= 2 > </c:foreach> <c:fortokens var= item items= <once)upon,a(time%there > delime= <),(%> > </c:fortokens> C:if tag=> The c:if tag is a simple conditional tag that evaluate its body if the supplied condition is true. The condition evaluated through its required attribute test. <c:if test= $i>3 > Test body </c:if> Developed by: Prof. ADNAN AHMAD PATHAN Page 13

14 C:choose tag=> the c:chose tag is a conditional tag that establishes a context for mutually exclusive conditional operations markes by the c:when and c:otherwise tags. These tag works like standard java switc- case-default. <c:choose> <c:when test= $i<3 >(less than 3)</c:when> <c:when test= $i<5 >(less than 5)</c:when> <c:otherwise>(greater than 5)</c:otherwise> </c:choose> c:set and c:remove Tags=> The c:set tag is used either for setting a scoped attribute or updating and creating bean properties and map values. <c:set var= attributename value= somevalue > <c:set target= bean property= name >pgi</c:set> The c:remove tag works by instructing it to remove the authors attribute from every scope by omitting the scope attribute. <c:remove var= attributename /> C:import tag=>the c:import tag can just as easily import content from the same container. In such cases you use the c:param tag in the exact same way as you would use the jsp:param with the jsp:include standard action. C:url and c:param Tag=> Just like encode URL method it encodes URL in its required value attribute appending the session id if the client browser is not using cookies. Just like the c:import tag the c:url tag is able to hold off on outputting the URL string if the optional var attribute is present. The c:url tag in combination with the c:param tag solves yet another problem. It is used if you need to append some parameters at the end of the URL. <c:url value= /out.jsp var= inputurl > <c:param name= name values= john dow /> </c:url> C:redirect Tag=>The c:redirect tag acts just like the sendredirecturl method of the HttpServletResponse class if its required url attribute specifies an absolute URL. <c:redirect url= <c:param name= h1 value= en /> <c:param name= q >core servlets</c:param> </c:redirect> C:catch tag=> The c:catch tag acts like the try/catch construct in java, except in the case of c:catch, there is no try. <c:catch var= myexception > <% int x=1/0; %> </c:catch> Developed by: Prof. ADNAN AHMAD PATHAN Page 14

15 Q23) Explain advantage of JSP over Servlet. OR Q24) What is the different between JSP and Servlet? Ans: Servlet is a java program that runs in conjuction with a web server. A servlet executed in response to an Http request from a client browser. The servlet executes and then returns an HTML page back to the browser. A JSP is text document that describes how a server should handle specific requests. A JSP run by a JSP server, which interprets the JSP and performs the action the page describes. The JSP server compiles the JSP into a servlet to enhance performance. The server would then periodically check the JSP for changes and if there is any change in JSP, the server will recompile it into a servlet. JSP initial acces slower than servlets because they need to be interpreted or compiled by the server, response time for initial accesses may be slower than servlets. JSP separates the presentation layer(i.e. web interface logic) from the business logic(i.e. back end content generation logic) JSP can only support HTTP Protocol. But a servlet can support any protocol like HTTP,FTP,SMTP etc. that s why JSP is used only mainly for presentation. 1] Servlet is a pure java class..whereas JSP is not... 2] We can put HTML Code inside servlets...and JSP. 3] when we use HTML in java code than it is called servlet and when we use Java code is html then it is called JSP.. Q25) What types of comments are available in the JSP? JSP Comments Example : JSP comment starts <%-- and end --%>. <%-- Two expressions are listed below. Only one should print. --%>.. Developed by: Prof. ADNAN AHMAD PATHAN Page 15

16 JDBC Q26) How does JDBC work? Explain JDBC API and also define objects of JDBC API. Ans: How Does JDBC WORK 1. Establish a connection with a data source 2. Send SQL queries and update statement to the data source 3. Process the result at the front end. JDBC JDBC Java Application JDBC Driver Database Component of Java database connectivity The Java application calls JDBC classes and interfaces to submit SQL statement and retrieve results. JDBC API Noe we will learn about the JDBC API. The JDBC API is implemented through the JDBC driver. The JDBC driver is a set of classes that implement the JDBC interfaces to process JDBC calls and return result set to a java application. The Databse(or data store) store the data retrieved by the application using the JDBC Driver. The API interface is made up of 4 main interfaces. 1. java.sql.drivermanager 2. java.sql.connection 3. java.sql.statement 4. java.sql.resultset in addition to these, the following support interface are also available to the developer. Developed by: Prof. ADNAN AHMAD PATHAN Page 16

17 Java.sql.driver Java.sql.Date Java.sql.Time Java.sql.Types Java.sql.Numeric The Main Objects of the JDBC API include: 1. A Data Source object is used to establish connection. Although the driver manager can also be used to establish a connection, connecting through a Data Source object is the preferred method. 2. A Connection object controls the connection to the database. An application uses the connection object to create statement. 3. Statement object are used for executing SQL queries. 4. A Result set object act like a workspace to store result of queries. A result set is returned to an application when a SQL query is executed by a statement object.. Q27) What are the JDBC? What are the advantages of using JDBC with java? Ans: JDBC is an API(Application Programming Interface)which consists of a set of java classes, interface and exceptions with the help of JDBC programming interface, java programmers can request a connection with a database, then send query statement using SQL and receive result of processing. According to Sun specialized JDBC drivers are available for all major databases including relational database from oracle corp., IBM, Microsoft Corp. The combination of Java with JDBC is very useful because it lets the programmers run his program on different platforms. Some of the advantages of using g java with JDBC are 1. Easy and economical 2. Continued usage of already installed database. 3. Development time is short. 4. Installation and version control simplified.. Q28) Why ODBC cannot be used directly with Java Program? Ans: ODBC can not used directly with java program due to various reason describe below. 1. ODBC can not be used directly with java because it uses C interface. This will have drawbacks in the security, implementation and robustness. 2. ODBC makes use of pointers which have been removed from java. 3. ODBC mixes simple and advanced feature together and has complex structure. Hence, JDBC came into existence Developed by: Prof. ADNAN AHMAD PATHAN Page 17

18 Q29) Give the standard steps for connecting and querying database with java application. Also discuss the important methods of Statement class. OR Q30) What is JDBC? How the transaction is carried out using JDBC API? Explain with Example. Ans: JDBC is an API(Application Programming Interface)which consists of a set of java classes, interface and exceptions with the help of JDBC programming interface, java programmers can request a connection with a database, then send query statement using SQL and receive result of processing. STEPS TO CONNECT TO A DATABASE: The Interface and classes of the JDBC API are present inside the package called as java.sql package.there any application using JDBC API must import java.sql package in its code. Import java.sql.*; STEP 1: Load the Drivers The first step in accessing the database is to load an appropriate driver.you can use one driver from the available four drivers which are described earlier.however, JDBC -ODBC Driver is the most preferred driver among developers.if you are using any other type of driver,then it shoud be installed on the system.in order to load the driver, you have to give the following syntax: Class.ForName( sun.jdbc.odbc.jdbcodbcdriver ); We can also the register the driver (if the third party driver) with the use of method registermethod() whose syntax is as follows: DriverManager.registerDriver(Driver dr); Where dr is the new JDBC driver to be registered with the driver manager. there are number of Step 2: Make the Connection The getconnection()method of the Driver Manager class is called to obtain the connection object. The syntax is Connection conn=drivermanager.getconnection( jdbc:odbc:<dsn NAME> ); Here note that getconnection() is a static method, meaning itshould be accessed along with class associated with the method.the DSN(DATA source Name) neme is the name which you gave in the control panel->odbc while registering the Database or table. Step 3: Create JDBC Statement A statement object is used to send SQL query to the database management system.you can simply create a statement object and then execute it.connection object conn here to create the statement object stmt the syntax is. Statement stmt=conn.createstatement(); As mentioned earlier we may use prepared Statement or callable Statement according to the requirement. Developed by: Prof. ADNAN AHMAD PATHAN Page 18

19 Step 4: Execute the Statement In order to execute the query you have to obtain the Result Set object similar to Record Set in Visual Basic and called the execute Query()method of the statement. Actually the recordset object contains both the data returned by query and the method for data retrival. The syntax is Result Set rs=stmt.executequery( select * from student ); The executeupdate() method is called whenever there is a delete or an update operation. Step 5: Navigation or looping through the ResultSet The ResultSet object contains rows of data that is parsed using the next() method like rs.next().we use the getxxx() like getint() to retrive Integer fields and getstring() for string fields. System.out.println(rs.getInt( id )); Step 6: Close the Connection and Statement Objects After performing all the above steps you must close the connection, statement and Result set object by calling the close () method. ResultSet object with rs.close(); Statement object with Stmt.close(); Connection object with Example: import java.sql.*; class Example2 public static void main(string args[]) try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); catch(classnotfoundexception cnf) System.out.println("Error : "+cnf); try Developed by: Prof. ADNAN AHMAD PATHAN Page 19

20 Connection con=drivermanager.getconnection("jdbc:odbc:emp"); Statement smt=con.createstatement(); int i=smt.executeupdate("insert INTO employee " + "VALUES (1008,'adnan')"); System.out.println(i); if(i==1) System.out.println("inserted"); con.close(); catch(sqlexception se) System.out.println("Error in SQL : "+se);.. Q31) What is the Statement? What is the use of PreparedStatement in JDBC? List out various methods of PreparedStatement. OR Q32) What are different types of statements available in JDBC? Where do we use these Statements? Ans: Statement object are used for executing SQL queries. In order to execute the query you have to obtain the Result Set object similar to Record Set in Visual Basic and called the execute Query()method of the statement. Actually the recordset object contains both the data returned by query and the method for data retrival. The syntax is Result Set rs=stmt.executequery( select * from student ); The executeupdate() method is called whenever there is a delete or an update operation. The executequery() method is called when select query is fired. Both methods are available into Statement class. Different Types of JDBC SQL Statement: 1. java.sql.statement: Top most interface which provides basic methods useful for executing SELECT, INSERT, UPDATE and DELETE SQL Statement. 2. java.sql.preparedstatement: it is an enhanced version of java.sql.statement which is used to execute SQL queries with parameters and can be executed multiple times. 3. java.sql.callablestatement: it allows you to execute stored procedures within a RDBMS which supports stored procedure. Developed by: Prof. ADNAN AHMAD PATHAN Page 20

21 Methods of PreparedStatement: PreparedStatement st= st = con.preparestatement(mysql); st.setint(1, 1007); st.setstring(2,"pandya Chaitanya"); st.setstring(3,"manager"); st.setstring(4," "); st.setint(5,15000); st.executeupdate();. Q33) What is the use of ResultSet in JDBS? Write a code in JDBC for view list of records from a table. Ans: A Result set object act like a workspace to store result of queries. A result set is returned to an application when a SQL query is executed by a statement object. Methods of ResultSet are getint() and getstring() and close(). CODE: import java.sql.*; class Example1 public static void main(string args[]) try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); catch(classnotfoundexception cnf) System.out.println("Error : "+cnf); try Connection con=drivermanager.getconnection("jdbc:odbc:emp"); Statement smt=con.createstatement(); ResultSet rs=smt.executequery("select * from employee"); while(rs.next()) System.out.println("empid="+rs.getInt(1)+"ename="+rs.getString(2)); catch(sqlexception se) System.out.println("Error in SQL : "+se);. Developed by: Prof. ADNAN AHMAD PATHAN Page 21

22 Q34) What is the most important package used in JDBC? Explain different methods to load the drivers in JDBC. Ans: The most important package used in JDBC is java.sql package. The first step in accessing the database is to load an appropriate driver 1. Class.ForName takes a string class name and loads the necessary class dynamically at run time as specified in the example to load the JDBC-ODBC driver following syntax may be used. Syntax: Class.ForName( sun.jdbc.odbc.jdbcodbcdriver ); 2. To register the third party driver one can use the method registermethod() whose syntax is follows: Syntax: DriverManager.registerDriver(Driver dr); 3. Use new to explicitly load the driver class. This hard codes the driver and (indirectly) the name of database into your program. 4. The System class has static property list.if this has a property jdbc.drivers set to a : separated list of driver class names, then all of these drivers will be loaded and registered automatically. Syntax: Properties props=new Properties(); FileInputStream in=new FileInputStream( Database.Properties ); Props.load(in); String drivers=props.getproperty(jdbc.drivers ); Class.forName(drivers);. Developed by: Prof. ADNAN AHMAD PATHAN Page 22

23 JSP & JDBC Developed by: Prof. ADNAN AHMAD PATHAN Page 23

Introduction to JSP and Servlets Training 5-days

Introduction to JSP and Servlets Training 5-days QWERTYUIOP{ Introduction to JSP and Servlets Training 5-days Introduction to JSP and Servlets training course develops skills in JavaServer Pages, or JSP, which is the standard means of authoring dynamic

More information

Unit 5 JSP (Java Server Pages)

Unit 5 JSP (Java Server Pages) Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications. It focuses more on presentation logic

More information

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Fast Track to Java EE 5 with Servlets, JSP & JDBC Duration: 5 days Description Java Enterprise Edition (Java EE 5) is a powerful platform for building web applications. The Java EE platform offers all the advantages of developing in Java plus a comprehensive

More information

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22.

a. Jdbc:ids://localhost:12/conn?dsn=dbsysdsn 21. What is the Type IV Driver URL? a. 22. Answers 1. What is the super interface to all the JDBC Drivers, specify their fully qualified name? a. Java.sql.Driver i. JDBC-ODBC Driver ii. Java-Native API Driver iii. All Java Net Driver iv. Java Native

More information

JSP MOCK TEST JSP MOCK TEST IV

JSP MOCK TEST JSP MOCK TEST IV http://www.tutorialspoint.com JSP MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to JSP Framework. You can download these sample mock tests at your local

More information

This course is intended for Java programmers who wish to write programs using many of the advanced Java features.

This course is intended for Java programmers who wish to write programs using many of the advanced Java features. COURSE DESCRIPTION: Advanced Java is a comprehensive study of many advanced Java topics. These include assertions, collection classes, searching and sorting, regular expressions, logging, bit manipulation,

More information

Unit 4 Java Server Pages

Unit 4 Java Server Pages Q1. List and Explain various stages of JSP life cycle. Briefly give the function of each phase. Ans. 1. A JSP life cycle can be defined as the entire process from its creation till the destruction. 2.

More information

JavaServer Pages. What is JavaServer Pages?

JavaServer Pages. What is JavaServer Pages? JavaServer Pages SWE 642, Fall 2008 Nick Duan What is JavaServer Pages? JSP is a server-side scripting language in Java for constructing dynamic web pages based on Java Servlet, specifically it contains

More information

Fast Track to Java EE

Fast Track to Java EE Java Enterprise Edition is a powerful platform for building web applications. This platform offers all the advantages of developing in Java plus a comprehensive suite of server-side technologies. This

More information

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP:

JSP - SYNTAX. Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP: http://www.tutorialspoint.com/jsp/jsp_syntax.htm JSP - SYNTAX Copyright tutorialspoint.com This tutorial will give basic idea on simple syntax ie. elements involved with JSP development: The Scriptlet:

More information

A Gentle Introduction to Java Server Pages

A Gentle Introduction to Java Server Pages A Gentle Introduction to Java Server Pages John Selmys Seneca College July 2010 What is JSP? Tool for developing dynamic web pages developed by SUN (now Oracle) High-level abstraction of Java Servlets

More information

Java Server Pages. JSP Part II

Java Server Pages. JSP Part II Java Server Pages JSP Part II Agenda Actions Beans JSP & JDBC MVC 2 Components Scripting Elements Directives Implicit Objects Actions 3 Actions Actions are XML-syntax tags used to control the servlet engine

More information

Database. Request Class. jdbc. Servlet. Result Bean. Response JSP. JSP and Servlets. A Comprehensive Study. Mahesh P. Matha

Database. Request Class. jdbc. Servlet. Result Bean. Response JSP. JSP and Servlets. A Comprehensive Study. Mahesh P. Matha Database Request Class Servlet jdbc Result Bean Response py Ki ta b JSP Ko JSP and Servlets A Comprehensive Study Mahesh P. Matha JSP and Servlets A Comprehensive Study Mahesh P. Matha Assistant Professor

More information

directive attribute1= value1 attribute2= value2... attributen= valuen %>

directive attribute1= value1 attribute2= value2... attributen= valuen %> JSP Standard Syntax Besides HTML tag elements, JSP provides four basic categories of constructors (markup tags): directives, scripting elements, standard actions, and comments. You can author a JSP page

More information

UNIT -5. Java Server Page

UNIT -5. Java Server Page UNIT -5 Java Server Page INDEX Introduction Life cycle of JSP Relation of applet and servlet with JSP JSP Scripting Elements Difference between JSP and Servlet Simple JSP program List of Questions Few

More information

Java Server Page (JSP)

Java Server Page (JSP) Java Server Page (JSP) CS 4640 Programming Languages for Web Applications [Based in part on SWE432 and SWE632 materials by Jeff Offutt] [Robert W. Sebesta, Programming the World Wide Web] 1 Web Applications

More information

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming PSD1B Advance Java Programming Unit : I-V PSD1B- Advance Java Programming 1 UNIT I - SYLLABUS Servlets Client Vs Server Types of Servlets Life Cycle of Servlets Architecture Session Tracking Cookies JDBC

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Java Server Pages (JSP) Dr. Basem Suleiman Service Oriented Computing Group, CSE, UNSW Australia Semester 1, 2016, Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2442

More information

About the Authors. Who Should Read This Book. How This Book Is Organized

About the Authors. Who Should Read This Book. How This Book Is Organized Acknowledgments p. XXIII About the Authors p. xxiv Introduction p. XXV Who Should Read This Book p. xxvii Volume 2 p. xxvii Distinctive Features p. xxviii How This Book Is Organized p. xxx Conventions

More information

PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II

PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II PES INSTITUTE OF TECHNOLOGY, SOUTH CAMPUS DEPARTMENT OF MCA INTERNAL TEST (SCHEME AND SOLUTION) II Subject Name: Advanced JAVA programming Subject Code: 13MCA42 Time: 11:30-01:00PM Max.Marks: 50M ----------------------------------------------------------------------------------------------------------------

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2017 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2465 1 Review:

More information

JSTL. JSTL (Java Standard Tag Library) is a collection of custom tags that are developed and maintained by the Jakarta project.

JSTL. JSTL (Java Standard Tag Library) is a collection of custom tags that are developed and maintained by the Jakarta project. JSTL JSTL (Java Standard Tag Library) is a collection of custom tags that are developed and maintained by the Jakarta project. To use them you need to download the appropriate jar and tld files for the

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411 1 Review:

More information

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0

Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0 Sun Sun Certified Web Component Developer for J2EE 5 Version 4.0 QUESTION NO: 1 To take advantage of the capabilities of modern browsers that use web standards, such as XHTML and CSS, your web application

More information

01KPS BF Progettazione di applicazioni web

01KPS BF Progettazione di applicazioni web 01KPS BF Progettazione di applicazioni web Introduction to Java Server Pages Fulvio Corno, Alessio Bosca Dipartimento di Automatica e Informatica Politecnico di Torino PAW - JSP intro 1 Introduction to

More information

JSP - ACTIONS. There is only one syntax for the Action element, as it conforms to the XML standard:

JSP - ACTIONS. There is only one syntax for the Action element, as it conforms to the XML standard: http://www.tutorialspoint.com/jsp/jsp_actions.htm JSP - ACTIONS Copyright tutorialspoint.com JSP actions use constructs in XML syntax to control the behavior of the servlet engine. You can dynamically

More information

Introduction to Java Server Pages. Enabling Technologies - Plug-ins Scripted Pages

Introduction to Java Server Pages. Enabling Technologies - Plug-ins Scripted Pages Introduction to Java Server Pages Jeff Offutt & Ye Wu http://www.ise.gmu.edu/~offutt/ SWE 432 Design and Implementation of Software for the Web From servlets lecture. Enabling Technologies - Plug-ins Scripted

More information

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, JSPs 1

CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, JSPs 1 CSc31800: Internet Programming, CS-CCNY, Spring 2004 Jinzhong Niu May 9, 2004 JSPs 1 As we know, servlets, replacing the traditional CGI technology, can do computation and generate dynamic contents during

More information

JSP. Basic Elements. For a Tutorial, see:

JSP. Basic Elements. For a Tutorial, see: JSP Basic Elements For a Tutorial, see: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/jspintro.html Simple.jsp JSP Lifecycle Server Web

More information

Chapter 10 Servlets and Java Server Pages

Chapter 10 Servlets and Java Server Pages Chapter 10 Servlets and Java Server Pages 10.1 Overview of Servlets A servlet is a Java class designed to be run in the context of a special servlet container An instance of the servlet class is instantiated

More information

ADVANCED JAVA TRAINING IN BANGALORE

ADVANCED JAVA TRAINING IN BANGALORE ADVANCED JAVA TRAINING IN BANGALORE TIB ACADEMY #5/3 BEML LAYOUT, VARATHUR MAIN ROAD KUNDALAHALLI GATE, BANGALORE 560066 PH: +91-9513332301/2302 www.traininginbangalore.com 2EE Training Syllabus Java EE

More information

SNS COLLEGE OF ENGINEERING, Coimbatore

SNS COLLEGE OF ENGINEERING, Coimbatore SNS COLLEGE OF ENGINEERING, Coimbatore 641 107 Accredited by NAAC UGC with A Grade Approved by AICTE and Affiliated to Anna University, Chennai IT6503 WEB PROGRAMMING UNIT 04 APPLETS Java applets- Life

More information

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab.

Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM Advanced Internet Technology Lab. Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 5049 Advanced Internet Technology Lab Lab # 10 JAVABEANS IN JSP El-masry May, 2014 Objectives Understanding JavaBeans.

More information

Java E-Commerce Martin Cooke,

Java E-Commerce Martin Cooke, Java E-Commerce Martin Cooke, 2002 1 Java technologies for presentation: JSP Today s lecture in the presentation tier Java Server Pages Tomcat examples Presentation How the web tier interacts with the

More information

JAVA 2 ENTERPRISE EDITION (J2EE)

JAVA 2 ENTERPRISE EDITION (J2EE) COURSE TITLE DETAILED SYLLABUS SR.NO JAVA 2 ENTERPRISE EDITION (J2EE) ADVANCE JAVA NAME OF CHAPTERS & DETAILS HOURS ALLOTTED SECTION (A) BASIC OF J2EE 1 FILE HANDLING Stream Reading and Creating file FileOutputStream,

More information

Table of Contents. Introduction... xxi

Table of Contents. Introduction... xxi Introduction... xxi Chapter 1: Getting Started with Web Applications in Java... 1 Introduction to Web Applications... 2 Benefits of Web Applications... 5 Technologies used in Web Applications... 5 Describing

More information

1. Introduction. 2. Life Cycle Why JSP is preferred over Servlets? 2.1. Translation. Java Server Pages (JSP) THETOPPERSWAY.

1. Introduction. 2. Life Cycle Why JSP is preferred over Servlets? 2.1. Translation. Java Server Pages (JSP) THETOPPERSWAY. 1. Introduction Java Server Pages (JSP) THETOPPERSWAY.COM Java Server Pages (JSP) is used for creating dynamic web pages. Java code can be inserted in HTML pages by using JSP tags. The tags are used for

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 1, 2017 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 12 (Wrap-up) http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2457

More information

20/08/56. Java Technology, Faculty of Computer Engineering, KMITL 1

20/08/56. Java Technology, Faculty of Computer Engineering, KMITL 1 Engineering, KMITL 1 Agenda What is JSP? Life-cycle of JSP page Steps for developing JSP-based Web application Dynamic contents generation techniques in JSP Three main JSP constructs Directives Error handling

More information

Session 12. JSP Tag Library (JSTL) Reading & Reference

Session 12. JSP Tag Library (JSTL) Reading & Reference Session 12 JSP Tag Library (JSTL) 1 Reading & Reference Reading Head First Chap 9, pages 439-474 Reference (skip internationalization and sql sections) Java EE 5 Tutorial (Chapter 7) - link on CSE336 Web

More information

Trabalhando com JavaServer Pages (JSP)

Trabalhando com JavaServer Pages (JSP) Trabalhando com JavaServer Pages (JSP) Sumário 7.2.1 Introdução 7.2.2 JavaServer Pages Overview 7.2.3 First JavaServer Page Example 7.2. Implicit Objects 7.2.5 Scripting 7.2.5.1 Scripting Components 7.2.5.2

More information

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

More information

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 12 (Wrap-up) http://webapps.cse.unsw.edu.au/webcms2/course/index.php?cid=2411

More information

Peers Techno log ies Pv t. L td. Core Java & Core Java &Adv Adv Java Java

Peers Techno log ies Pv t. L td. Core Java & Core Java &Adv Adv Java Java Page 1 Peers Techno log ies Pv t. L td. Course Brochure Core Java & Core Java &Adv Adv Java Java Overview Core Java training course is intended for students without an extensive programming background.

More information

ADVANCED JAVA COURSE CURRICULUM

ADVANCED JAVA COURSE CURRICULUM ADVANCED JAVA COURSE CURRICULUM Index of Advanced Java Course Content : 1. Basics of Servlet 2. ServletRequest 3. Servlet Collaboration 4. ServletConfig 5. ServletContext 6. Attribute 7. Session Tracking

More information

Model View Controller (MVC)

Model View Controller (MVC) Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 5049 Advanced Internet Technology Lab Lab # 11 Model View Controller (MVC) El-masry May, 2014 Objectives To be

More information

1Z Java EE 6 Web Component Developer Certified Expert Exam Summary Syllabus Questions

1Z Java EE 6 Web Component Developer Certified Expert Exam Summary Syllabus Questions 1Z0-899 Java EE 6 Web Component Developer Certified Expert Exam Summary Syllabus Questions Table of Contents Introduction to 1Z0-899 Exam on Java EE 6 Web Component Developer Certified Expert... 2 Oracle

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

JavaServer Pages. Juan Cruz Kevin Hessels Ian Moon

JavaServer Pages. Juan Cruz Kevin Hessels Ian Moon Page 1 of 14 JavaServer Pages Table of Contents 1. Introduction What is JSP? Alternative Solutions Why Use JSP? 2. JSP Process Request Compilation Example 3. Object Instantiation and Scope Scope Synchronization

More information

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres sessionx Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano EL Expression Language Write the code in something else, just let EL call it. EL () EL stand for Expression

More information

What's New in the Servlet and JSP Specifications

What's New in the Servlet and JSP Specifications What's New in the Servlet and JSP Specifications Bryan Basham Sun Microsystems, Inc bryan.basham@sun.com Page 1 Topics Covered History Servlet Spec Changes JSP Spec Changes: General JSP Spec Changes: Expression

More information

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. Preface p. xiii Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p. 11 Creating the Deployment Descriptor p. 14 Deploying Servlets

More information

Trabalhando com JavaServer Pages (JSP)

Trabalhando com JavaServer Pages (JSP) Trabalhando com JavaServer Pages (JSP) Sumário 7.2.1 Introdução 7.2.2 JavaServer Pages Overview 7.2.3 First JavaServer Page Example 7.2.4 Implicit Objects 7.2.5 Scripting 7.2.5.1 Scripting Components 7.2.5.2

More information

112-WL. Introduction to JSP with WebLogic

112-WL. Introduction to JSP with WebLogic Version 10.3.0 This two-day module introduces JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for Web applications under the Java Enterprise platform. The module begins

More information

JDBC [Java DataBase Connectivity]

JDBC [Java DataBase Connectivity] JDBC [Java DataBase Connectivity] Introduction Almost all the web applications need to work with the data stored in the databases. JDBC is Java specification that allows the Java programs to access the

More information

JSTL ( )

JSTL ( ) JSTL JSTL JSTL (Java Standard Tag Library) is a collection of custom tags that are developed by the Jakarta project. Now it is part of the Java EE specication. To use them you need to download the appropriate

More information

JavaServer Pages (JSP)

JavaServer Pages (JSP) JavaServer Pages (JSP) The Context The Presentation Layer of a Web App the graphical (web) user interface frequent design changes usually, dynamically generated HTML pages Should we use servlets? No difficult

More information

112. Introduction to JSP

112. Introduction to JSP 112. Introduction to JSP Version 2.0.2 This two-day module introduces JavaServer Pages, or JSP, which is the standard means of authoring dynamic content for Web applications under the Java Enterprise platform.

More information

Oracle 10g: Build J2EE Applications

Oracle 10g: Build J2EE Applications Oracle University Contact Us: (09) 5494 1551 Oracle 10g: Build J2EE Applications Duration: 5 Days What you will learn Leading companies are tackling the complexity of their application and IT environments

More information

Experiment No: Group B_2

Experiment No: Group B_2 Experiment No: Group B_2 R (2) N (5) Oral (3) Total (10) Dated Sign Problem Definition: A Web application for Concurrent implementation of ODD-EVEN SORT is to be designed using Real time Object Oriented

More information

Ch04 JavaServer Pages (JSP)

Ch04 JavaServer Pages (JSP) Ch04 JavaServer Pages (JSP) Introduce concepts of JSP Web components Compare JSP with Servlets Discuss JSP syntax, EL (expression language) Discuss the integrations with JSP Discuss the Standard Tag Library,

More information

LTBP INDUSTRIAL TRAINING INSTITUTE

LTBP INDUSTRIAL TRAINING INSTITUTE Java SE Introduction to Java JDK JRE Discussion of Java features and OOPS Concepts Installation of Netbeans IDE Datatypes primitive data types non-primitive data types Variable declaration Operators Control

More information

Enterprise Computing with Java MCA-305 UNIT II. Learning Objectives. JSP Basics. 9/17/2013MCA-305, Enterprise Computing in Java

Enterprise Computing with Java MCA-305 UNIT II. Learning Objectives. JSP Basics. 9/17/2013MCA-305, Enterprise Computing in Java Enterprise Computing with Java MCA-305 UNIT II Bharati Vidyapeeth s Institute of Computer Applications and Management, New Delhi-63, by Ms. Ritika Wason UII. # Learning Objectives JSP Basics and Architecture:

More information

A- Core Java Audience Prerequisites Approach Objectives 1. Introduction

A- Core Java Audience Prerequisites Approach Objectives 1. Introduction OGIES 6/7 A- Core Java The Core Java segment deals with the basics of Java. It is designed keeping in mind the basics of Java Programming Language that will help new students to understand the Java language,

More information

AN ISO 9001:2008 CERTIFIED COMPANY ADVANCED. Java TRAINING.

AN ISO 9001:2008 CERTIFIED COMPANY ADVANCED. Java TRAINING. AN ISO 9001:2008 CERTIFIED COMPANY ADVANCED Java TRAINING www.webliquids.com ABOUT US Who we are: WebLiquids is an ISO (9001:2008), Google, Microsoft Certified Advanced Web Educational Training Organisation.

More information

Specialized - Mastering JEE 7 Web Application Development

Specialized - Mastering JEE 7 Web Application Development Specialized - Mastering JEE 7 Web Application Development Code: Lengt h: URL: TT5100- JEE7 5 days View Online Mastering JEE 7 Web Application Development is a five-day hands-on JEE / Java EE training course

More information

Pace University. Fundamental Concepts of CS121 1

Pace University. Fundamental Concepts of CS121 1 Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

More information

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly,

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly, Session 21 Expression Languages 1 Reading Java EE 7 Chapter 9 in the Tutorial 2 11/7/2018 1 Lecture Objectives Understand how Expression Languages can simplify the integration of data with a view Know

More information

A JavaBean is a class file that stores Java code for a JSP

A JavaBean is a class file that stores Java code for a JSP CREATE A JAVABEAN A JavaBean is a class file that stores Java code for a JSP page. Although you can use a scriptlet to place Java code directly into a JSP page, it is considered better programming practice

More information

Advantage of JSP over Servlet

Advantage of JSP over Servlet JSP technology is used to create web application just like Servlet technology. It can be thought of as an extension to servlet because it provides more functionality than servlet such as expression language,

More information

Oracle 1z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Practice Test. Version:

Oracle 1z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Practice Test. Version: Oracle 1z0-858 Java Enterprise Edition 5 Web Component Developer Certified Professional Exam Practice Test Version: 14.21 QUESTION NO: 1 To take advantage of the capabilities of modern browsers that use

More information

More JSP. Advanced Topics in Java. Khalid Azim Mughal Version date: ATIJ More JSP 1/42

More JSP. Advanced Topics in Java. Khalid Azim Mughal   Version date: ATIJ More JSP 1/42 More JSP Advanced Topics in Java Khalid Azim Mughal khalid@ii.uib.no http://www.ii.uib.no/~khalid/atij/ Version date: 2006-09-04 ATIJ More JSP 1/42 Overview Including Resources in JSP Pages using the jsp:include

More information

Oracle EXAM - 1Z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Buy Full Product

Oracle EXAM - 1Z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Buy Full Product Oracle EXAM - 1Z0-858 Java Enterprise Edition 5 Web Component Developer Certified Professional Exam Buy Full Product http://www.examskey.com/1z0-858.html Examskey Oracle 1Z0-858 exam demo product is here

More information

JSP Scripting Elements

JSP Scripting Elements JSP Scripting Elements Core Servlets & JSP book: More Servlets & JSP book: www.moreservlets.com Servlet and JSP Training Courses: courses.coreservlets.com 1 Slides Marty Hall, http://, book Sun Microsystems

More information

Session 11. Expression Language (EL) Reading

Session 11. Expression Language (EL) Reading Session 11 Expression Language (EL) 1 Reading Reading Head First pages 368-401 Sun Java EE 5 Chapter 5 in the Tutorial java.sun.com/javaee/5/docs/tutorial/doc/javaeetutorial.pdf / / / / / Reference JSTL

More information

JavaServer Pages and the Expression Language

JavaServer Pages and the Expression Language JavaServer Pages and the Expression Language Bryan Basham Sun Microsystems, Inc. bryan.basham@sun.com Page 1 Topics Covered History of the Expression Language (EL) Overview of the EL EL Namespace EL Operators

More information

Integrating Servlets and JavaServer Pages Lecture 13

Integrating Servlets and JavaServer Pages Lecture 13 Integrating Servlets and JavaServer Pages Lecture 13 Core Servlets & JSP book: More Servlets & JSP book: www.moreservlets.com Servlet and JSP Training Courses: courses.coreservlets.com 1 Slides Marty Hall,

More information

C H A P T E RJSP.2. JSP.2.1 Syntax of expressions in JSP pages: ${} vs #{}

C H A P T E RJSP.2. JSP.2.1 Syntax of expressions in JSP pages: ${} vs #{} C H A P T E RJSP.2 Expression Language As of JSP 2.1, the expression languages of JSP 2.0 and JSF 1.1 have been merged into a single unified expression language (EL 2.1) for the benefit of all Java based

More information

Java Server Pages, JSP

Java Server Pages, JSP Java Server Pages, JSP Java server pages is a technology for developing web pages that include dynamic content. A JSP page can change its content based on variable items, identity of the user, the browsers

More information

JAVA MICROSERVICES. Java Language Environment. Java Set Up. Java Fundamentals. Packages. Operations

JAVA MICROSERVICES. Java Language Environment. Java Set Up. Java Fundamentals. Packages. Operations Java Language Environment JAVA MICROSERVICES Object Oriented Platform Independent Automatic Memory Management Compiled / Interpreted approach Robust Secure Dynamic Linking MultiThreaded Built-in Networking

More information

MARATHWADA INSTITUTE OF TECHNOLOGY, AURANGABAD DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS ADVANCE JAVA QUESTION BANK

MARATHWADA INSTITUTE OF TECHNOLOGY, AURANGABAD DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS ADVANCE JAVA QUESTION BANK MARATHWADA INSTITUTE OF TECHNOLOGY, AURANGABAD DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS ADVANCE JAVA QUESTION BANK Second Year MCA 2013-14 (Part-I) Faculties: Prof. V.V Shaga Prof. S.Samee Prof. A.P.Gosavi

More information

JSP MOCK TEST JSP MOCK TEST III

JSP MOCK TEST JSP MOCK TEST III http://www.tutorialspoint.com JSP MOCK TEST Copyright tutorialspoint.com This section presents you various set of Mock Tests related to JSP Framework. You can download these sample mock tests at your local

More information

Advanced Java Programming

Advanced Java Programming Advanced Java Programming Length: 4 days Description: This course presents several advanced topics of the Java programming language, including Servlets, Object Serialization and Enterprise JavaBeans. In

More information

CE212 Web Application Programming Part 3

CE212 Web Application Programming Part 3 CE212 Web Application Programming Part 3 30/01/2018 CE212 Part 4 1 Servlets 1 A servlet is a Java program running in a server engine containing methods that respond to requests from browsers by generating

More information

Java Server Pages. Copyright , Xiaoping Jia. 7-01/54

Java Server Pages. Copyright , Xiaoping Jia. 7-01/54 Java Server Pages What is Java Server Pages (JSP)? HTML or XML pages with embedded Java code to generate dynamic contents. a text-based document that describes how to process a request and to generate

More information

CHAPTER 1. Core Syntax Reference

CHAPTER 1. Core Syntax Reference CHAPTER 1 Core Syntax Reference 1 Output Comment Generates a comment that is sent to the client in the viewable page source. JSP Syntax Examples Example 1

More information

Watch Core Java and Advanced Java Demo Video Here:

Watch Core Java and Advanced Java Demo Video Here: Website: http://www.webdesigningtrainingruchi.com/ Contact person: Ranjan Raja Moble/Whatsapp: +91-9347045052 / 09032803895 Dilsukhnagar, Hyderabad Email: webdesigningtrainingruchi@gmail.com Skype: Purnendu_ranjan

More information

Server-side Web Programming

Server-side Web Programming Server-side Web Programming Lecture 20: The JSP Expression Language (EL) Advantages of EL EL has more elegant and compact syntax than standard JSP tags EL lets you access nested properties EL let you access

More information

Basic Principles of JSPs

Basic Principles of JSPs 5 IN THIS CHAPTER What Is a JSP? Deploying a JSP in Tomcat Elements of a JSP Page Chapter 4, Basic Principles of Servlets, introduced you to simple Web applications using servlets. Although very useful

More information

Advance Java. Configuring and Getting Servlet Init Parameters per servlet

Advance Java. Configuring and Getting Servlet Init Parameters per servlet Advance Java Understanding Servlets What are Servlet Components? Web Application Architecture Two tier, three tier and N-tier Arch. Client and Server side Components and their relation Introduction to

More information

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently.

More information

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype="text/html; charset=windows-31j" import="java.util.calendar" %>

A.1 JSP A.2 JSP JSP JSP. MyDate.jsp page contenttype=text/html; charset=windows-31j import=java.util.calendar %> A JSP A.1 JSP Servlet Java HTML JSP HTML Java ( HTML JSP ) JSP Servlet Servlet HTML JSP MyDate.jsp

More information

Anno Accademico Laboratorio di Tecnologie Web. Sviluppo di applicazioni web JSP

Anno Accademico Laboratorio di Tecnologie Web. Sviluppo di applicazioni web JSP Universita degli Studi di Bologna Facolta di Ingegneria Anno Accademico 2007-2008 Laboratorio di Tecnologie Web Sviluppo di applicazioni web JSP http://www lia.deis.unibo.it/courses/tecnologieweb0708/

More information

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실 데이타베이스시스템연구실 Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실 Overview http://www.tutorialspoint.com/jsp/index.htm What is JavaServer Pages? JavaServer Pages (JSP) is a server-side programming

More information

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft

More information

MANTHLY TEST SEPTEMBER 2017 QUESTION BANK CLASS: XII SUBJECT: INFORMATICS PRACTICES (065)

MANTHLY TEST SEPTEMBER 2017 QUESTION BANK CLASS: XII SUBJECT: INFORMATICS PRACTICES (065) MANTHLY TEST SEPTEMBER 2017 QUESTION BANK CLASS: XII SUBJECT: INFORMATICS PRACTICES (065) DATABASE CONNECTIVITY TO MYSQL Level- I Questions 1. What is the importance of java.sql.*; in java jdbc connection?

More information

Advanced Web Systems 3- Portlet and JSP-JSTL. A. Venturini

Advanced Web Systems 3- Portlet and JSP-JSTL. A. Venturini Advanced Web Systems 3- Portlet and JSP-JSTL A. Venturini Contents Portlet: doview flow Handling Render phase Portlet: processaction flow Handling the action phase Portlet URL Generation JSP and JSTL Sample:

More information

JavaEE Interview Prep

JavaEE Interview Prep Java Database Connectivity 1. What is a JDBC driver? A JDBC driver is a Java program / Java API which allows the Java application to establish connection with the database and perform the database related

More information

Java Server Pages JSP

Java Server Pages JSP Java Server Pages JSP Agenda Introduction JSP Architecture Scripting Elements Directives Implicit Objects 2 A way to create dynamic web pages Introduction Separates the graphical design from the dynamic

More information

DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER

DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER DVS WEB INFOTECH DEVELOPMENT TRAINING RESEARCH CENTER J2EE CURRICULUM Mob : +91-9024222000 Mob : +91-8561925707 Email : info@dvswebinfotech.com Email : hr@dvswebinfotech.com 48, Sultan Nagar,Near Under

More information