servlet technology - web application...
TRANSCRIPT
Servlet TechnologyWeb Application Development
Zsolt Tóth
University of Miskolc
2017
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 1 / 26
Back-end Programming Languages
1 Back-endProgramming LanguagesApplication Servers
2 Web ApplicationsStructureDeployment Descriptor
3 J2EEHttpServletFilter
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 2 / 26
Back-end Programming Languages
Common Gateway Interface
CGI Program / ScriptPHP, CGenerate HTML
Started by the Web ServerCreate process for eachHTTP RequestCostly
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 3 / 26
Back-end Programming Languages
Script Languages
PHPMost popular
Local companies use it.Frameworks
YiiContent ManagementSystems
JoomlaWordPress
Easy–to–startSupported by web serverhosting companiesWikipedia
PythonHigh–level, general purposelanguagePopular but not in MiskolcEasy–to–LearnGoogle, Youtube
RubyRuby on Rails FrameworkNot popular in MiskolcTwitter
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 4 / 26
Back-end Programming Languages
Object Oriented Languages
Web ApplicationsComplex,Reliable,Stable
Expensive InfrastructureComponents can beseparated easilyGood, well-tested code(hopefully ,)
DevelopmentSlowStandardized
Fixed rolesMethodologies
DifficultIf you do it well ,Lots of technology
Both Java and C# are used bylocal companies
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 5 / 26
Back-end Application Servers
Overview
ApplicationMiddlewareSoftware FrameworkEnvironment for DynamicWeb ApplicationsContains
Servlet ContainerJSPEnterprise JavaBeans
ServersGlassFish, WildFly,Geronimo
$ WebSphere, WebLogic,JBoss
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 6 / 26
Back-end Application Servers
Common Tasks
Admin ConsoleDeploymentScaling
Manage NodesClustering
MonitoringServerApplicationsResources
Resource ManagementJDBCJNDIJMS
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 7 / 26
Back-end Application Servers
Installation
Java ApplicationPlatforms
UnixLinuxWindows
No install.exe
Extract and runScript files
bin/startup.shbin/shutdown.sh
Hints for DevelopersYour are not a SystemAdministrator.You should not operate anApplication Server.Logging is essential.Log files grow quickly.Never run as root!
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 8 / 26
Back-end Application Servers
Usage as a Developer
Local DeploymentManual TestingDemonstration
≈ Test Server
IDE IntegrationEclipseIntelliJ IDEANetBeans
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 9 / 26
Back-end Application Servers
Tomcat
Apache Software FoundationLightweightServlet ContainerVersions
8.0Servlet 3.1JSP 2.3
8.5HTTP/2OpenSSL
Popular among developers!
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 10 / 26
Back-end Application Servers
Tomcat
Directoriesbin
Script filesstartup.shshutdown.sh
confXMLserver.xmltomcat-users.xml
webapps
.+-- bin+-- conf+-- lib+-- LICENSE+-- logs+-- NOTICE+-- RELEASE-NOTES+-- RUNNING.txt+-- temp+-- webapps\-- work
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 11 / 26
Back-end Application Servers
Tomcat for Developers
IDEIntelliJ IDEAEclipse
Multiple ServersLocal Configuration
Workspace
Start/Stop ServerDeploymentRefresh / Restart
TasksRun LocallyTest Manually
See alsoDatabase ManagementSoftware TestingOperation Systems
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 12 / 26
Web Applications Structure
1 Back-endProgramming LanguagesApplication Servers
2 Web ApplicationsStructureDeployment Descriptor
3 J2EEHttpServletFilter
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 13 / 26
Web Applications Structure
Structure
Web AppExpected Directory StructureStandard LocationsDeployed from Web ARchive
Root DirectoryStatic ContentDirect Access
+-- images+-- index.jsp+-- META-INF| \-- context.xml+-- WEB-INF| +-- jsp| | +-- 401.jsp| | +-- 403.jsp| | +-- 404.jsp| | \-- sessions.jsp| \-- web.xml
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 14 / 26
Web Applications Structure
Web ARchive
ZIP File
*.war ExtensionContains Web ApplicationCreation
jar cvf ...Maven Packaging
Can be Deployed
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 15 / 26
Web Applications Structure
WEB-INF
Cannot be Accessed Directly!
classes
*.class filesCompiled Servlet ClassesPackage Structure
lib
*.jar Files3rd Party Dependencies
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 16 / 26
Web Applications Deployment Descriptor
Deployment Descriptor
WEB-INF/web.xml
Details of Web ApplicationNameDescriptionServlet DefinitionURL MappingListenersFilters. . .
1 <web-app xmlns="..."><servlet>
3 <servlet-name>greetings
5 </servlet-name><servlet-class>
7 org.dummy.Greetings</servlet-class>
9 </servlet><servlet-mapping>
11 <servlet-name>greetings
13 </servlet-name><url-pattern>/</url-pattern>
15 </servlet-mapping></web-app>
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 17 / 26
Web Applications Deployment Descriptor
Servlet Mapping
servlet tagIdentified by nameservlet-class
Instanceinit-param
Initialization
load
servlet-mapping
Key Value pairExtends application’s URL* wild card
http://host:port/WebAppName/path
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 18 / 26
Web Applications Deployment Descriptor
Filters
filter
filter-name Identifierfilter-class
Similar to ServletPreprocessingForwarding / Rejection
filter-mapping
filter-name
Selectionurl-patternservlet-name
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 19 / 26
Web Applications Deployment Descriptor
Context-Param
Context InitializationKey-Value ParisAvailable in JavaPredefined Keys
contextConfigLocation
<context-param><param-name>contextConfigLocation
</param-name><param-value>/dispatcher-servlet.xml/applicationContext.xml
</param-value></context-param>
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 20 / 26
J2EE HttpServlet
1 Back-endProgramming LanguagesApplication Servers
2 Web ApplicationsStructureDeployment Descriptor
3 J2EEHttpServletFilter
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 21 / 26
J2EE HttpServlet
Servlet
javax.servlet
InterfaceGeneric Methods
initservicedestroy
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 22 / 26
J2EE HttpServlet
HttpServlet
javax.servlet.http
Implements ServletRun in Servlet ContainerMethods
doGetdoPostdoPutdoDelete
doGet(2 HttpServletRequest req,
HttpServletResponse resp){4 //do something
}
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 23 / 26
J2EE HttpServlet
HttpServletRequest
Request InformationgetCookies
getSession
getHeaders
getParameter
getQueryString
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 24 / 26
J2EE HttpServlet
HttpServletResponse
Servlet ResponseHTTP HeaderCookiesadd*
sendError
getWriter
getOutputStream
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 25 / 26
J2EE Filter
Filter
PreprocessingMethods
initdoFilterdestroy
TypesAuthentication FiltersLogging and Auditing FiltersImage conversion FiltersData compression FiltersEncryption FiltersTokenizing FiltersFilters that trigger resourceaccess eventsXSL/T filtersMime-type chain Filter
Zsolt Tóth (University of Miskolc) Servlet Technology 2017 26 / 26