The document discusses Java Server Pages (JSP) technology. It explains that JSP allows separation of work between web designers and developers by allowing HTML design and Java coding. A JSP page compiles to a servlet, sharing features with servlets like platform independence and database-driven applications. However, servlets tie static and dynamic content across multiple files while JSP allows embedding Java code directly into HTML pages. The document also covers JSP tags, directives, the JSP life cycle, and core JSP classes.
Mumbai Academics is Mumbai’s first dedicated Professional Training Center for Training with Spoke and hub model with Multiple verticles . The strong foundation of Mumbai Academics is laid by highly skilled and trained Professionals, carrying mission to provide industry level input to the freshers and highly skilled and trained Software Professionals/other professional to IT companies.
This slide is about basics of java servlet and java server page.
A basic example of JSP using multiple directives.
Further information of setting up and using of Apache Tomcat server.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
Mumbai Academics is Mumbai’s first dedicated Professional Training Center for Training with Spoke and hub model with Multiple verticles . The strong foundation of Mumbai Academics is laid by highly skilled and trained Professionals, carrying mission to provide industry level input to the freshers and highly skilled and trained Software Professionals/other professional to IT companies.
This slide is about basics of java servlet and java server page.
A basic example of JSP using multiple directives.
Further information of setting up and using of Apache Tomcat server.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
JAVA EE DEVELOPMENT (JSP and Servlets)Talha Ocakçı
Java and J2EE is the most used technologies in enterprise web development. Telecom operators, service providers are using these technlogies; banking and insurance companies are moving to Java from old generation technologies.
https://www.udemy.com/java-web-developmen-with-real-world-development-flow
If you want to earn much in web development business, you also need to learn Java web technologies.
Java has de facto standart frameworks such as EJB 3.0, Spring and others that can be bound to them.
But at heart, they all use the similar JSP/Servlet technology and add some layers above them to speed up the development.
You will use them in your daily business but before using them, you must learn the basics and what is going on while using them. Otherwise, you will not be able to find a proper solution to common problems.
This course will make you understand the basics of JSP / servlet technlogies, designing a relational database, DB operations, design patterns, working with other developers,
and let you know the must-do operations in professional projects such as performance increasing, logging errors.
If you want to develop a web-site in a couple of hours without understanding what you are doing, you may go ahead and find other resources. But if you really want to understand what you are doing and learn the theory at the same time, this course will be a great oppurtunity for you. You will develop a real working project. Yow will first write quick and dirty code then you will apply professional patterns one by one while investigating the problems.
You will walk through a real development flow:
1- Write a quick and dirty code for doing the job.
2- You will design database tables and high performance queries
3 - You will apply design patterns to make the code reusable and high performance.
4 - You will beautify the user interface with Javascript and CSS tweaks
5- You will add exception handling, logging mechanism for production environment
6- AT THIS STEP, YOU WILL BE HIRED FOR MUCH MUCH HIGHER SALARIES. BECAUSE YOU ARE A REAL PROFESSIONAL.
Server side programs can be written using different server-side technologies , such as Common Gateway Interface (CGI) , Active Server Pages (ASP) and Servlets.
CGI scripts are written in C , C++ or perl programming languages .
In case of an application server using CGI script to process client request , the server creates a separate instance of the CGI script to process the request.
As a result, the efficiency of the server is affected when there is large number of concurrent requests.
jsp implicit objects (predefined java objects)
jsp implicit objects are java objects that the jsp container makes available to developers in each page so that developer can call them directly without being explicitly declared......
there are 9 pre defined objects in jsp... which are being discussed in this ppt with diagram representation and fewer points..... not full information in slides ... just prepared for presentation purpose.... so u have to do the research work from internet and you tube.....
this ppt is self prepared and taken reference form you tube
JAVA EE DEVELOPMENT (JSP and Servlets)Talha Ocakçı
Java and J2EE is the most used technologies in enterprise web development. Telecom operators, service providers are using these technlogies; banking and insurance companies are moving to Java from old generation technologies.
https://www.udemy.com/java-web-developmen-with-real-world-development-flow
If you want to earn much in web development business, you also need to learn Java web technologies.
Java has de facto standart frameworks such as EJB 3.0, Spring and others that can be bound to them.
But at heart, they all use the similar JSP/Servlet technology and add some layers above them to speed up the development.
You will use them in your daily business but before using them, you must learn the basics and what is going on while using them. Otherwise, you will not be able to find a proper solution to common problems.
This course will make you understand the basics of JSP / servlet technlogies, designing a relational database, DB operations, design patterns, working with other developers,
and let you know the must-do operations in professional projects such as performance increasing, logging errors.
If you want to develop a web-site in a couple of hours without understanding what you are doing, you may go ahead and find other resources. But if you really want to understand what you are doing and learn the theory at the same time, this course will be a great oppurtunity for you. You will develop a real working project. Yow will first write quick and dirty code then you will apply professional patterns one by one while investigating the problems.
You will walk through a real development flow:
1- Write a quick and dirty code for doing the job.
2- You will design database tables and high performance queries
3 - You will apply design patterns to make the code reusable and high performance.
4 - You will beautify the user interface with Javascript and CSS tweaks
5- You will add exception handling, logging mechanism for production environment
6- AT THIS STEP, YOU WILL BE HIRED FOR MUCH MUCH HIGHER SALARIES. BECAUSE YOU ARE A REAL PROFESSIONAL.
Server side programs can be written using different server-side technologies , such as Common Gateway Interface (CGI) , Active Server Pages (ASP) and Servlets.
CGI scripts are written in C , C++ or perl programming languages .
In case of an application server using CGI script to process client request , the server creates a separate instance of the CGI script to process the request.
As a result, the efficiency of the server is affected when there is large number of concurrent requests.
jsp implicit objects (predefined java objects)
jsp implicit objects are java objects that the jsp container makes available to developers in each page so that developer can call them directly without being explicitly declared......
there are 9 pre defined objects in jsp... which are being discussed in this ppt with diagram representation and fewer points..... not full information in slides ... just prepared for presentation purpose.... so u have to do the research work from internet and you tube.....
this ppt is self prepared and taken reference form you tube
JavaScript, often abbreviated as JS, is a programming language and core techn...MathivananP4
JavaScript, often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. As of 2024, 98.9% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries.
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 accuracy.
A JSP page consists of HTML tags and JSP tags. The JSP pages are easier to maintain than Servlet because we can separate designing and development. It provides some additional features such as Expression Language, Custom Tags, etc. Extension to Servlet, Easy to maintain, Fast Development: No need to recompile and redeploy, Less code than Servlet
Its an distributed enviornment for developing the enterprise application.We can develop multi-tier,three-tier or n-tier architecture using this.In this Java Server Pages and Servlet is the important things
Dear students get fully solved assignments
Send your semester & Specialization name to our mail id :
“ help.mbaassignments@gmail.com ”
or
Call us at : 08263069601
(Prefer mailing. Call in emergency )
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
Atul & shubha goswami jsp
1. J S P
Java Server Pages
Mr. Atul Giri
BY -: &
Ms. Shubha Goswami
2. JSP technology has facilitated the segregation of the work of
a Web designer and a Web developer.
A Web designer can design and formulate the layout for the
Web page by using HTML.
On the other hand, a Web developer working independently
can use java code and other JSP specific tags to code the
business logic.
The simultaneous construction of the static and dynamic
content facilitates development of quality applications with
increased productivity.
3. A JSP page , after compilation , generates a servlet and
therefore incorporates all servlet functionalities.
Servlets and JSP thus share common features, such as
platform independence , creation of database-driven Web
applications , and server side programming capabilities.
However , there are also some basic differences between
servlets and JSP :
4. Servlets tie up files (an HTML file for the static content and a
Java file for the dynamic contents) to independently handle the
static presentation logic and the dynamic business logic.
Due to this , a change made to any file requires recompilation
of the servlet.
JSP on the other hand allows Java to be embedded directly into
an HTML page by using tags.
The HTML content and the Java content can also be placed in
separate files.
Any changes made to HTML content is automatically compiled
and loaded onto the servlet
5. Servlet programming involves extensive coding.
Therefore, any change made to the code requires identification
of the static code content (for the designer) and dynamic code
content (for the developer) to facilitate incorporation of the
changes.
On the other hand, a JSP page, by virtue of the separate
placement of the static and dynamic content , facilitates both
Web developers and the Web designer to work independently.
6. JSP Life Cycle
When the client browser requests for a particular JSP page ,the
server in turns sends a request to the JSP engine.
A JSP engine is a part of a Web container , that compiles a JSP
page to a servlet.
The following figure represents the process of the flow of
events that occur after a client requests for a JSP page.
7. Request-Response Cycle for a JSP Page
Browser
Web
Container
( JSP
Engine)
Yes
No
Response
Response
Check to ensure if
the call to JSP is
first of its kind
Servlet
generation and
recompilation
Servlet
reloaded
Request
Response
8. The request-response cycle essentially comprises of two phases , namely
the translation phase and the request-processing phase.
The translation phase is implemented by the JSP engine and involves
generation of a servlet.
Internally , this results in the creation of a class file for the JSP page ,that
implements the servlet interface.
During the request-processing phase, the response is generated according
to the request specifications.
After the servlet is loaded for the first time, it remains active , processes all
the subsequent requests , and saves time that would otherwise be lost in
reloading a servlet at each time.
9. Once a JSP is translated to a servlet , the container invokes the
following life cycle methods on the servlet , that are defined in
the javax.servlet.jsp.JspPage interface:
1. jspInit() : This method is invoked at the time when the servlet
is initialized.
2. jspService() : This method is invoked when request for the JSP
page is received.
3. jspDestroy() : This method is invoked before the servlet is
removed from the service.
10. Assignment
Accept two numbers form the user form the AcceptInput.jsp
page .
Create Calculate.jsp to process the request and displays the
results
12. IncludePage.jsp
<html>
<body>
<h4> Today’s Date is :
<jsp:include page=“DatePage.jsp” flush=“true” /> </h4>
<%
out.println(“<h4> The ouput of the file DatePage.jsp is shown
above </h3>”);
%>
</body>
</html>
13. Classes of JSP API
JSP API is a set of classes and interfaces that you can use to
create a JSP pages.
These classes and interfaces are contained in the
javax.servlet.jsp package .
Some of the classes defined in the javax.servlet.jsp package
are :
1. ErrorData
2. JspWriter
3. PageContext
14. The ErrorData Class
The ErrorData class defines error information for error pages.
You need to set the value of the page directive , isErrorPage
to be true to indicate that a page is an error page.
The ErrorData class extends the java.lang.Object class .
Some of the methods defined in the ErrorData class that you
can use in a jsp page are :
15. 1. getRequestURL () :
-> Returns the requested URL in the form of a String.
2. getServletName () :
-> Returns the name of the servlet invoked in the form of a
String.
3. getStatusCode () :
-> Returns the status code of the error in the form of an interger.
4. getThrowable () :
-> Returns the Throwable exception that caused the error.
16. The JspWriter Class
The JspWriter class is used to write action and template data in
a JSP page.
The object of JspWriter class is referenced by the implicit
variable , out .
The JspWriter class extends the java.io.Writer class.
Some of the methos defined in the JspWriter class that you can
use in a JSP page are :
17. 1. clear() :
-> Clears the contents of the buffer. The clear() method throws an
IOException exception , if the buffer is already cleared.
2. close() :
-> Closes and flushes the stream
3. flush() :
->Flushes the buffer stream. The flush() method flushes all the buffers in a
chain of Writers and OutputStream.It throws java.io.IOException exception
if you make a call to the write () or flush() after closing the stream
18. 4. getBufferSize () :
-> Returns the size of the buffer used by the JspWriter
5. print() :
-> Prints a value of type boolean , interger ,character ,long integer , floating
point , double –precision floating –point number, an array of character ,
string , and object. The print() throws the java.io.IOException exception if
any error occurs while printing.
6. println() :
-> Prints a value of type boolean , interger ,character ,long integer , floating
point , double –precision floating –point number, an array of character ,
string , and object.This method writes a line separator string to terminate
the current line. The Println () throws the java.io.IOException exception if
any error occurs while printing
19. The PageContext Class
The PageContext class provides context information when the
JSP technology is used in the servlet environment.
The PageContext class extends the JspContext class.
A PageContext instances provides access to namespaces
associated with a JSP page.
Some of the methods defined in the PageContext class are :
20. 1. forward () :
-> Redirects the current servlet request and servlet response to another
page. This method accepts the URL of a target page as an argument.
2. getPage () :
->Returns the current value of the page object.
3. getRequest () :
-> Returns the current value of the request object. The return type of the
getRequest () is the servlet request.
4. getResponse():
-> Returns the current value of the response object. The return type of the
getResponse () method is the servlet response.
21. 5. getServletConfig ():
-> Returns the ServletConfig of the current page.
6. getServletContext () :
-> Returns the ServletContext of the current page.
7. getSession () :
->Returns the HttpSession for the current PageContext. The return type of
getSession () is HttpSession.
8. include () :
->Processes the current servlet request and the response specified in the
URL. The include () method asscepts two arguments, a URL path and the
flush value of boolean type
22. <html>
<head>
<title>My first JSP Page</title>
</head>
<body>
<%@page language=“java”%>
<% System.out.println(“Be in Peace”); %>
</body>
<html>
23. Using JSP tags
There are five main tags:
1. Declaration tag
2. Expression tag
3. Directive tag
4. Scriptlet tag
5. Action tag
24. Declaration tag (<%! %>)
This tag allows the developer to declare variables or methods.
Before the declaration you must have <%! And at the end of the declaration
the developer must have %>
Code placed in this must end in a semicolon(;).
Declarations do not generate output, so are used with JSP expressions or
scriptlets.
25. Example Of Declaration tag
<%!
private int counter = 0 ;
private String getAccount (int accountNo);
%>
26. Expression tag (<%= %>)
This tag allows the developer to embed any java expression
and is short for out.println().
A semicolon (;) does not appear at the end of the code inside
the tag.
28. Directive tag (<%@ directive…. %>)
A JSP directive gives special information about the jsp page , to the JSP
Engine.
There are three main types of directives:
1. page - processing information for this page
2. Include - files to be included
3. Tag library - tag library to be used in this page
29. Directive tag (Continue…..)
Directives do not produce any visible output when the page is
requested but change the way the JSP engine processes the
page.
For example , you can make session data unavailable to a
page by setting a page directive (session) to false.
30. 1. Page directive
This directive has 11 optional attributes that provides the JSP
Engine with special processing information.
The following table lists the 11 different attributes with a brief
description.
31. Language : Which language the file uses.
<%@ page language=“java” %>
Import : Import all the classes in a java package
into the current JSP page.This alllows the
JSP page to use other java classes.
The following packages are implicitly imported.
java.lang.*
javax.servlet.*
javax.servlet.jsp.*
javax.servlet.http.*
<%@ page import=“java.util.*” %>
32. session : Does the page make use of sessions.
By default all JSP pages have session data available.
Default is set to true.
buffer : Controls the use of the buffered output for the
JSP page. Default is 8 kb
<%@page buffer =“none” %>
autoFlush : Flush output buffer when full
<%@ page autoFlush=“true” %>
33. isThreadSafe : Can the generated Servlet deal
with multiple requests?
If true a new thread is started
so requests are handled simultaneously.
info : Developer uses info attribute to add
information/document for a page.
Typically used to add author , version,
copyright and date info
<%@ page info=“abc.com test page,copyright 2001.” %>
34. errorPage : Different page to deal with errors.
Must be URL to error page
<%@ page errorPage=“/error/error.jsp” %>
isErrorPage : This flag is set to true to make a JSP page
a special Error Page.
This page has access to the implicit object exception
35. 2.Include directive
Allows a JSP developer to include contents of a file inside
another.
Typically include files are used for navigation, tables , headers
and footers that are common to multiple pages.
36. Two examples of using include files:
This include the html from privacy.html found in the include
directory into the current jsp page.
<%@ include file = “include/privacy.html” %>
OR
To include a navigation menu (jsp file ) found in the current
directory.
<%@ include file = “navigation.jsp” %>
37. 3.Tag Lib directive
A tag lib is a collection of the custom tags that can be used by
the page.
<%@ taglib uri=“tag lib URI” prefix=“tag Prefix” %>
Custom tags were introduced in JSP 1.1 and allow JSP
developers to hide complex server side code from web
designers.
38. Scriptlet tag (<%... %>)
Between <% and %> tags , any valid Java Code is called a
Scriptlet.
This code can access any variable or bean declared.
39. For example , to print a variable .
<%
String message = “Be in Peace” ;
out.println(message);
%>
40. Action tag
There are three main roles of the action tags:
Enable the use of the server side Javabeans.
Transfer control between pages
browser independent support for applets
41. Javabeans
A Javabeans is a special type of the class that has a number of
methods.
The JSP page can call these methods so can leave most of the
code in these Javabeans.
For example, if you wanted to make a feedback form that
automatically sent out an email. By having a JSP page with a
form, when the visitors presses the submit button this sends
the details to a JavaBeans that sends out the emails. This way
there would be no code in the JSP page dealing with sending
emails.
42. To use a Javabean in a JSP page use the following syntax:
<jsp:usebean id=“ id” scope=“application” class=“…….” />
43. The following is a list of Javabean scopes:
page –
valid until page completes
request –
bean instance lasts for the client request.
session –
bean lasts for the client session
application –
bean instance created and lasts until application ends.
44. Dynamic JSP Include
You have seen how a file can be included into a JSP using an
include Directive:
<%@ include file = “include/privacy.html”%>
This is a useful for including common pages that are shared and
is included at compile time.
To include a page at run time you should use dynamic JSP
includes.
<jsp:include page=“URL” flush=“true”/>
45. <HTML>
<HEAD>
<TITLE> JSP Example </TITLE>
</HEAD>
<BODY>
JSP Example <BR>
<%!
String message = “Be in Peace”;
int counter = 0 ;
%>
Todays Message is
<%=message%> <Br>
Counter is <%=counter%>
</BODY>
</HTML>
46. Implicit Objects
There are several objects that are automatically available
in JSP called implicit objects.
47. Variable Of type
request javax.servlet.http.httpServletRequest
response javax.servlet.http.httpServletResponse
out javax.servlet.jsp.JspWriter
session javax.servlet.http.HttpSession
pagecontent javax.servlet.jsp.PageContext
application javax.servlet.http.ServletContext
config javax.servlet.http.ServletConfig
page javax.lang.Object
exception java.lang.Throwable
48. page object -
Represents the JSP page and is used to call any
methods defined by the servlet class.
config object -
Stores the Servlet configuration data.
49. request object
Access to information associated with a request. This
object is normally used in looking up parameter values and
cookies.
<% String str = request.getParameter(“uname”); %>
50. Session Tracking in JSP (Session Object)
Cookies – a small text file stored on the clients machine.
Cookie can be disables in the browser settings so are not
always available.
URL rewriting – store session information in the URL. Works
when cookies are not supported but can make bookmarking of
web pages a problem because they have session specific
information at the end of a URL.
51. Hidden form fields - HTML hidden edit boxes such as
<input type = “hidden” name=“user” value=“ ---”>
Session objects – JSP Implicit Object
52. A session object uses a key / value combination to store
information.
To retrieve information from a session:
session.getValue(“msg”)
The return type of the method getValue is Object , so you will
need to typecast to get the reuired value. If there is not a
session key with that name , null is returned.
53. To set a session key with a value,
session.putValue (“msg” , val)
54. JSP comments<%-- JSP comment--%>
JSP comments are similar to HTML comments
<!– HTML comment -- >
except JSP comments are never sent to the user’s browser.
HTML comments are visible in the page source.
55. <html>
<head>
<title>
HTML and JSP Comments
</title>
</head>
<body>
<h2> Comments </h2>
<!— This HTML Comment-visible in the page source -->
<%-- This JSP comment-Not visible in the page source -- %>
</body>
</html>
56. Error pages
Eventually there will come a time when sometime unexpected
happens.
In Java terms, this is when an exception gets thrown.
JSP can handle these situations so when an exception is
thrown , a default error page is sent to the browser.
So what makes an error page different from other JSP pages?
57. One of the first lines in an error page must be the page directive
isErrorPage=“true”
Inside your default error page (errorPage.jsp), above
the<HTML> tag type:
<%@ page isErrorPage=“true” import=“java.util.*” %>
<HTML>
<BODY>
Error Occurred
<%= exception.toString() %>
</Body>
<HTML>
58. Our error page also uses the exception object and the
toString() method to display a brief description of the error.
To use a specific error page in your JSP pages, again above
the <HTML> tag type:
<%@ page errorPage=“errorPage.jsp”%>
<HTML>
………..
</HTML>
This code will go to errorPage.jsp if an error occurs.
Even after an error, the HTTP session remains available.
61. In JSP 1.2 , it is not necessary that the errorPage value be a
JSP page.
It can also be a static file , such as an HTML page:
<%@ page errorPage = “errorHandler.html” %>
62. The Need for JSP
• With servlets, it is easy to
– Read form data
– Read HTTP request headers
– Set HTTP status codes and response headers
– Use cookies and session tracking
– Share data among servlets
– Remember data between requests
– Get fun, high-paying jobs
• But, it sure is a pain to
– Use those println statements to generate HTML
– Maintain that HTML
63. The JSP Framework
• Idea:
– Use regular HTML for most of page
– Mark servlet code with special tags
– Entire JSP page gets translated into a servlet (once), and servlet is
what actually gets invoked (for each request)
• Example:
<HTML>
<HEAD>
<TITLE>Order Confirmation</TITLE>
</HEAD>
<BODY>
<H2>Order Confirmation</H2>
Thanks for ordering <I> <%= request.getParameter("title") %> </I> !
</BODY>
</HTML>
64. Benefits of JSP
– Write HTML.
– Read and maintain the HTML.
– Use standard HTML tools such as Macromedia DreamWeaver or Adobe
GoLive.
– Have different members of your team do the HTML layout than do the
Java programming.
– Separate the (Java) code that creates the content from the (HTML)
code that presents it.
65. Advantages of JSP Over Competing Technologies
• Versus ASP or ColdFusion
– Better language for dynamic part
– Portable to multiple servers and operating systems
• Versus PHP
– Better language for dynamic part
– Better tool support
• Versus pure servlets
– More convenient to create HTML
– Can use standard tools (e.g., DreamWeaver)
– Divide and conquer
– JSP programmers still need to know servlet programming
66. • Versus Velocity or WebMacro
– Standard
• Versus client-side JavaScript (in browser)
– Capabilities mostly do not overlap with JSP, but
• You control server, not client
• Richer language
• Versus server-side JavaScript (e.g., LiveWire, BroadVision)
– Richer language
• Versus static HTML
– Dynamic features
– Adding dynamic features no longer "all or nothing" decision
67. Setting Up Your Environment
• Set your CLASSPATH : Not.
• Compile your code : Not.
• Use packages to avoid name conflicts : Not.
• Put JSP page in special directory: Not.
• Use special URLs to invoke JSP page: Not.
– Use same URLs as for HTML pages (except for file extensions)
69. <HTML>
<BODY>
<%
// This is a scriptlet. Notice that the "date"
// variable we declare here is available in the
// embedded expression later on.
System.out.println( "Evaluating date now“ );
java.util.Date date = new java.util.Date();
%>
Hello! The time is now :
<%= date %>
</BODY>
</HTML>
70. <HTML>
<BODY>
<%
// This scriptlet declares and initializes "date"
System.out.println( "Evaluating date now" );
java.util.Date date = new java.util.Date();
%>
Hello! The time is now
<%
// This scriptlet generates HTML output
out.println( String.valueOf( date ));
%>
</BODY>
</HTML>
71. <HTML>
<BODY>
<%
// This scriptlet declares and initializes "date"
System.out.println( "Evaluating date now" );
java.util.Date date = new java.util.Date();
%>
Hello! The time is now
<%
out.println( date );
out.println( "<BR>Your machine's address is " );
out.println( request.getRemoteHost() );
%>
</BODY>
</HTML>
72. <TABLE BORDER=2>
<%
for ( int i = 0; i < n; i++ )
{
%>
<TR>
<TD> Number </TD>
<TD> <%= i+1 %> </TD>
</TR>
<%
}
%>
</TABLE>
73. <%
if ( hello )
{
%>
<P> Hello, world
<%
}
else
{
%>
<P>Goodbye, world
<%
}
%>
74. JSP Directives
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%
System.out.println( "Evaluating date now" );
Date date = new Date();
%>
Hello! The time is now
<%= date %>
</BODY>
</HTML>
The first line in the above example is called a "directive".
A JSP "directive" starts with <%@ characters.
<%@ page import= "java.util.*, java.text.*" %>
75. The include directive is used to physically include the contents of another
file.
The included file can be HTML or JSP or anything else -- the result is as if
the original JSP file actually contained the included text.
<HTML>
<BODY>
Going to include hello.jsp...<BR>
<%@ include file="hello.jsp" %>
</BODY>
</HTML>
76. JSP Declarations
<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%!
Date theDate = new Date();
Date getDate()
{
System.out.println( "In getDate() method“);
return theDate;
}
%>
Hello! The time is now
<%= getDate() %>
</BODY>
</HTML>
85. Answers
1. All primitive literals are fine.
2. No! The semicolon can’t be here.
3. String literal is fine.
4. Yes, the method returns a double.
5. No! you can’t have a variable declaration here.
6. Yes , because the new String array is an object , and ANY object can be
sent to a println() statement.
7. No! The arithmetic is fine , but there’s a space between the % and the =.
It can’t be <% = , it must be <%=
8. Sure , this resolves to a boolean, so it prints ‘true’.
9. Primitive literals are fine
10. No problem. This is just like the String [] …. It prints the result of the
object’s toString() method.
86. Will it compile? Will it Work?
<html>
<body>
<%
int count = 0;
%>
The page count is :
<%= ++count %>
</body>
</html>
If it compiles see the O/P
87. What Really happens to your JSP code?
This JSP:
<html>
<body>
<% int count = 0; %>
The Page count is now :
<%= ++count %>
</body>
</html>
88. Becomes this servlet:
public class basicCounter_jsp extends SomeSpecialHttpServlet
{
public void _jspservice(HttpServletRequest req,HttpServletResponse resp)
throws java.io.IOException , ServletException
{
PrintWriter out = response.getWriter();
response.setContentType(“text/html”);
out.write(“<html><body>”);
int count = 0;
out.write(“The page count is now:”);
out.print(++count);
out.write(“</body></html>”);
}
}