Download Core basic Java web server technologies - Maria

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

URL shortening wikipedia , lookup

URL redirection wikipedia , lookup

Transcript
Core basic Java web server
technologies
Tools
• Eclipse IDE for Java EE
Developers (Netbeans also
works)
http://www.eclipse.org/dow
nloads/packages/eclipseide-java-eedevelopers/keplersr2
• Application server (e.g.
Tomcat, GlassFish)
https://tomcat.apache.org/
download-80.cgi#8.0.28
Create a
dynamic web
project
JSPs (Java Servlet Pages)
• JSPs are one of the core building blocks of Java web applications,
allowing us to combine HTML and Java seamlessly
• JSP lifecycle: http://www.tutorialspoint.com/jsp/jsp_life_cycle.htm
• We can embed Java code into JSP with scriptlet tags
Scriplets
<%
java.util.Date today = new java.util.Date();
String mess = "Today is "+today;
%>
<%= mess %>
Or
<%
Output
java.util.Date today = new java.util.Date();
String mess = "Today is "+today;
out.println(mess);
%>
Press CTRL+Space
For deployment
Steps for deployment on your local computer
• Right-click on the project->Export->WAR
• Copy the war file into webapps folder from your Tomcat installation
folder
• Close the Tomcat from
Eclipse and open it from
Startup
• You should be able to see
the results when calling your
web application from localhost
• You can deploy your web application for free on
https://www.openshift.com , Google App Engine, etc by uploading
your war
How to import Java classes into JSPs
How to retrieve parameters from the URL in
JSPs
Java Servlet
• A servlet is a Java class that runs in an "application server" and sends
web pages back to a browser when a user somewhere in the world
clicks on a URL.
To get some URL parameters…
Work with scriplets and HTML
The include directive vs the include jsp tag
• Static include includes smth into the page, before compiling and sending it to the browser (directive)
• Dynamic include takes place at runtime (jsp tag)
Going from jsp page/servlet to another jsp
page/servlet
• In forward, you see the content of your forwarded page, but the url of the initial page.
• In redirect, you see for a second the content of your initial page, then you see your redirected page and, also, its
url.
Declaration tag
Summary of JSP tags so far…