SlideShare a Scribd company logo
JSP & STRUTS
#122065
#122076
#122107
#122139
#122141
#122199
JSP -Java Server Pages
The purpose of a servlet is to create a Web page in
response to a client request
Servlets are written in Java, with a little HTML mixed in
JSP is an alternate way of creating servlets
 JSP is written as ordinary HTML, with a little Java mixed in
 The Java is enclosed in special tags .
 The HTML is known as the template text
JSP files must have the extension .jsp
2
JSP scripting elements
There is more than one type of JSP “tag”
depending on what you want done with the Java
<%= expression %>
 The expression is evaluated and the result is inserted into
the HTML page
<% code %>
 The code is inserted into the servlet's service method
 This construction is called a scriptlet
 <%! declarations %>
 The declarations are inserted into the servlet class, not into
a method
3
4
Example JSP
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY>
</HTML>
Notes:
 The <%= ... %> tag is used, because we are computing a value and
inserting it into the HTML
 The fully qualified name (java.util.Date) is used, instead of the short
name (Date).
Variables
You can declare your own variables, as usual
JSP provides several predefined variables
 request : The HttpServletRequest parameter
 response : The HttpServletResponse parameter
 session : The HttpSession associated with the request, or
null if there is none
 out : A JspWriter (like a PrintWriter) used to send output
to the client
Example:
 Your hostname: <%= request.getRemoteHost() %>
5
Scriptlets
Scriptlets are enclosed in <% ... %> tags
 Scriptlets do not produce a value that is inserted directly into
the HTML (as is done with <%= ... %>)
 Scriptlets are Java code that may write into the HTML
 Example:
<% String queryData = request.getQueryString();
out.println("Attached GET data: " + queryData); %>
Scriptlets are inserted into the servlet exactly as
written, and are not compiled until the entire servlet is
compiled
6
Declarations
Use <%! ... %> for declarations to be added to
servlet class, not to any particular method
 Servlets are multithreaded, so nonlocal variables must be
handled with extreme care
 If declared with <% ... %>, variables are local and OK
 Data can also safely be put in the request or session objects
Example:
<%! private int accessCount = 0; %>
Accesses to page since server reboot:
<%= ++accessCount %>
Use <%! ... %> to declare methods as easily as to
declare variables
7
JSP in XML
JSP can be embedded in XML as well as in HTML
Due to XML’s syntax rules, the tags must be different (but
they do the same things)
HTML: <%= expression %>
XML: <jsp:expression>expression</jsp:expression>
HTML: <% code %>
XML: <jsp:scriptlet>code</jsp:scriptlet>
HTML: <%! declarations %>
XML: <jsp:declaration>declarations</jsp:declaration>
HTML: <%@ include file=URL %>
XML: <jsp:directive.include file="URL"/>
8
Struts
 Struts is an open-source framework for building more
flexible, maintainable and structured front-ends in Java
web applications
 There are two key components in a web application:
the data and business logic performed on this data
the presentation of data
 Struts
helps structuring these components in a Java web app.
controls the flow of the web application, strictly separating these
components
unifies the interaction between them
9
Why struts are useful
structural separation of data presentation and business logic
Struts provides a Controller that manages the control flow
easy localization
based on standard Java technologies
open-source
10
THANK YOU !!!
11

More Related Content

What's hot

Java script
Java scriptJava script
Java script
Fajar Baskoro
 
Asp.Net MVC - Razor Syntax
Asp.Net MVC - Razor SyntaxAsp.Net MVC - Razor Syntax
Asp.Net MVC - Razor Syntax
Renier Serven
 
Java script
Java scriptJava script
Java script
ITz_1
 
Rest hello world_tutorial
Rest hello world_tutorialRest hello world_tutorial
Rest hello world_tutorial
Aravindharamanan S
 
How to Create and Load Model in Laravel
How to Create and Load Model in LaravelHow to Create and Load Model in Laravel
How to Create and Load Model in Laravel
Yogesh singh
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
Neil Crookes
 
Html To JSP
Html To JSPHtml To JSP
Html To JSP
PlanetB4U
 
Java Script
Java ScriptJava Script
Java Script
husbancom
 
servlet programming
servlet programmingservlet programming
servlet programming
Rumman Ansari
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
Randy Connolly
 
Lab work servlets and jsp
Lab work servlets and jspLab work servlets and jsp
Lab work servlets and jsp
Rajiv Gupta
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
ambuj pathak
 
Learn html and css from scratch
Learn html and css from scratchLearn html and css from scratch
Learn html and css from scratch
Mohd Manzoor Ahmed
 
Java script
Java scriptJava script
Java script
Ravinder Kamboj
 
Lecture6
Lecture6Lecture6
Lecture6
Sazilah Salam
 

What's hot (20)

Java script
Java scriptJava script
Java script
 
Asp.Net MVC - Razor Syntax
Asp.Net MVC - Razor SyntaxAsp.Net MVC - Razor Syntax
Asp.Net MVC - Razor Syntax
 
Java script
Java scriptJava script
Java script
 
Rest hello world_tutorial
Rest hello world_tutorialRest hello world_tutorial
Rest hello world_tutorial
 
Lecture6
Lecture6Lecture6
Lecture6
 
How to Create and Load Model in Laravel
How to Create and Load Model in LaravelHow to Create and Load Model in Laravel
How to Create and Load Model in Laravel
 
Ajax
AjaxAjax
Ajax
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Html To JSP
Html To JSPHtml To JSP
Html To JSP
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
Java Script
Java ScriptJava Script
Java Script
 
servlet programming
servlet programmingservlet programming
servlet programming
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
 
Java server pages
Java server pagesJava server pages
Java server pages
 
2310 b 03
2310 b 032310 b 03
2310 b 03
 
Lab work servlets and jsp
Lab work servlets and jspLab work servlets and jsp
Lab work servlets and jsp
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Learn html and css from scratch
Learn html and css from scratchLearn html and css from scratch
Learn html and css from scratch
 
Java script
Java scriptJava script
Java script
 
Lecture6
Lecture6Lecture6
Lecture6
 

Similar to Jsp & struts

Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Shah Nawaz Bhurt
 
Jsp
JspJsp
Jsp 01
Jsp 01Jsp 01
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
Sasidhar Kothuru
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yo
michael
 
JSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODSJSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODS
bharathiv53
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
Rajavel Dhandabani
 
Jsp element
Jsp elementJsp element
Jsp element
kamal kotecha
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
Subhasis Nayak
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
NishaRohit6
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
Yoga Raja
 
Introduction to JSP pages
Introduction to JSP pagesIntroduction to JSP pages
Introduction to JSP pages
Fulvio Corno
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
Kaml Sah
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
Smita B Kumar
 
Jsp
JspJsp
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSPGeethu Mohan
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Ayes Chinmay
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
ManishaPatil932723
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
Vipin Yadav
 
Unit 4 1 web technology uptu
Unit 4 1 web technology uptuUnit 4 1 web technology uptu
Unit 4 1 web technology uptu
Abhishek Kesharwani
 

Similar to Jsp & struts (20)

Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Jsp
JspJsp
Jsp
 
Jsp 01
Jsp 01Jsp 01
Jsp 01
 
Jsp sasidhar
Jsp sasidharJsp sasidhar
Jsp sasidhar
 
JSP diana y yo
JSP diana y yoJSP diana y yo
JSP diana y yo
 
JSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODSJSP AND XML USING JAVA WITH GET AND POST METHODS
JSP AND XML USING JAVA WITH GET AND POST METHODS
 
Jsp servlets
Jsp servletsJsp servlets
Jsp servlets
 
Jsp element
Jsp elementJsp element
Jsp element
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
 
JSP.pptx
JSP.pptxJSP.pptx
JSP.pptx
 
JSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGESJSP- JAVA SERVER PAGES
JSP- JAVA SERVER PAGES
 
Introduction to JSP pages
Introduction to JSP pagesIntroduction to JSP pages
Introduction to JSP pages
 
J2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - ComponentsJ2EE - JSP-Servlet- Container - Components
J2EE - JSP-Servlet- Container - Components
 
Advance java session 10
Advance java session 10Advance java session 10
Advance java session 10
 
Jsp
JspJsp
Jsp
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
 
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
Internet and Web Technology (CLASS-14) [JSP] | NIC/NIELIT Web Technology
 
Introduction to JSP.pptx
Introduction to JSP.pptxIntroduction to JSP.pptx
Introduction to JSP.pptx
 
JSP - Java Server Page
JSP - Java Server PageJSP - Java Server Page
JSP - Java Server Page
 
Unit 4 1 web technology uptu
Unit 4 1 web technology uptuUnit 4 1 web technology uptu
Unit 4 1 web technology uptu
 

More from Hansi Thenuwara

Natural language processing
Natural language processingNatural language processing
Natural language processing
Hansi Thenuwara
 
Travel sri lanka
Travel sri lankaTravel sri lanka
Travel sri lanka
Hansi Thenuwara
 
Mobile based electricity
Mobile based electricityMobile based electricity
Mobile based electricity
Hansi Thenuwara
 
Case study3
Case study3Case study3
Case study3
Hansi Thenuwara
 
Scrum methodology
Scrum methodologyScrum methodology
Scrum methodology
Hansi Thenuwara
 
ICT boom in India
ICT boom in IndiaICT boom in India
ICT boom in India
Hansi Thenuwara
 
New dimensions of technology
New dimensions of technologyNew dimensions of technology
New dimensions of technology
Hansi Thenuwara
 
Cleaner production
Cleaner productionCleaner production
Cleaner production
Hansi Thenuwara
 
Tourism industry in Sri Lanka
Tourism industry in Sri LankaTourism industry in Sri Lanka
Tourism industry in Sri Lanka
Hansi Thenuwara
 
Operations Management Study in Textured Jersy Lanka Limited
Operations Management Study in Textured Jersy Lanka LimitedOperations Management Study in Textured Jersy Lanka Limited
Operations Management Study in Textured Jersy Lanka Limited
Hansi Thenuwara
 
UML Class Diagram G-3-122139
UML Class Diagram G-3-122139UML Class Diagram G-3-122139
UML Class Diagram G-3-122139Hansi Thenuwara
 
Channelling Management System
Channelling Management SystemChannelling Management System
Channelling Management SystemHansi Thenuwara
 

More from Hansi Thenuwara (13)

Natural language processing
Natural language processingNatural language processing
Natural language processing
 
Travel sri lanka
Travel sri lankaTravel sri lanka
Travel sri lanka
 
Mobile based electricity
Mobile based electricityMobile based electricity
Mobile based electricity
 
Case study3
Case study3Case study3
Case study3
 
Scrum methodology
Scrum methodologyScrum methodology
Scrum methodology
 
ICT boom in India
ICT boom in IndiaICT boom in India
ICT boom in India
 
New dimensions of technology
New dimensions of technologyNew dimensions of technology
New dimensions of technology
 
Cleaner production
Cleaner productionCleaner production
Cleaner production
 
Tourism industry in Sri Lanka
Tourism industry in Sri LankaTourism industry in Sri Lanka
Tourism industry in Sri Lanka
 
Operations Management Study in Textured Jersy Lanka Limited
Operations Management Study in Textured Jersy Lanka LimitedOperations Management Study in Textured Jersy Lanka Limited
Operations Management Study in Textured Jersy Lanka Limited
 
UML Class Diagram G-3-122139
UML Class Diagram G-3-122139UML Class Diagram G-3-122139
UML Class Diagram G-3-122139
 
Patient management
Patient managementPatient management
Patient management
 
Channelling Management System
Channelling Management SystemChannelling Management System
Channelling Management System
 

Recently uploaded

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 

Recently uploaded (20)

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 

Jsp & struts

  • 2. JSP -Java Server Pages The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little HTML mixed in JSP is an alternate way of creating servlets  JSP is written as ordinary HTML, with a little Java mixed in  The Java is enclosed in special tags .  The HTML is known as the template text JSP files must have the extension .jsp 2
  • 3. JSP scripting elements There is more than one type of JSP “tag” depending on what you want done with the Java <%= expression %>  The expression is evaluated and the result is inserted into the HTML page <% code %>  The code is inserted into the servlet's service method  This construction is called a scriptlet  <%! declarations %>  The declarations are inserted into the servlet class, not into a method 3
  • 4. 4 Example JSP <HTML> <BODY> Hello! The time is now <%= new java.util.Date() %> </BODY> </HTML> Notes:  The <%= ... %> tag is used, because we are computing a value and inserting it into the HTML  The fully qualified name (java.util.Date) is used, instead of the short name (Date).
  • 5. Variables You can declare your own variables, as usual JSP provides several predefined variables  request : The HttpServletRequest parameter  response : The HttpServletResponse parameter  session : The HttpSession associated with the request, or null if there is none  out : A JspWriter (like a PrintWriter) used to send output to the client Example:  Your hostname: <%= request.getRemoteHost() %> 5
  • 6. Scriptlets Scriptlets are enclosed in <% ... %> tags  Scriptlets do not produce a value that is inserted directly into the HTML (as is done with <%= ... %>)  Scriptlets are Java code that may write into the HTML  Example: <% String queryData = request.getQueryString(); out.println("Attached GET data: " + queryData); %> Scriptlets are inserted into the servlet exactly as written, and are not compiled until the entire servlet is compiled 6
  • 7. Declarations Use <%! ... %> for declarations to be added to servlet class, not to any particular method  Servlets are multithreaded, so nonlocal variables must be handled with extreme care  If declared with <% ... %>, variables are local and OK  Data can also safely be put in the request or session objects Example: <%! private int accessCount = 0; %> Accesses to page since server reboot: <%= ++accessCount %> Use <%! ... %> to declare methods as easily as to declare variables 7
  • 8. JSP in XML JSP can be embedded in XML as well as in HTML Due to XML’s syntax rules, the tags must be different (but they do the same things) HTML: <%= expression %> XML: <jsp:expression>expression</jsp:expression> HTML: <% code %> XML: <jsp:scriptlet>code</jsp:scriptlet> HTML: <%! declarations %> XML: <jsp:declaration>declarations</jsp:declaration> HTML: <%@ include file=URL %> XML: <jsp:directive.include file="URL"/> 8
  • 9. Struts  Struts is an open-source framework for building more flexible, maintainable and structured front-ends in Java web applications  There are two key components in a web application: the data and business logic performed on this data the presentation of data  Struts helps structuring these components in a Java web app. controls the flow of the web application, strictly separating these components unifies the interaction between them 9
  • 10. Why struts are useful structural separation of data presentation and business logic Struts provides a Controller that manages the control flow easy localization based on standard Java technologies open-source 10