Java Server Pages (JSPs)
120 likes | 291 Views
Java Server Pages (JSPs). Like Perl and PHP, Server-side scripting Similar to PHP Static HTML/XML components Special JSP tags Snippets of code written in Java (called scriptlets). Java Server Pages (JSPs). Scriptlets written in Java access to complete Java environment scalability
Java Server Pages (JSPs)
E N D
Presentation Transcript
Java Server Pages (JSPs) • Like Perl and PHP, Server-side scripting • Similar to PHP • Static HTML/XML components • Special JSP tags • Snippets of code written in Java (called scriptlets)
Java Server Pages (JSPs) • Scriptlets written in Java • access to complete Java environment • scalability • portability
Java Server Pages (JSPs) • <html> • <title>Demo a simple JSP program</title> • <body> • <%= “Hello world” %> • </body></html>
Java Server Pages (JSPs) • JSP implicit objects • Among others (will visit later): • out, a JspWriter object that writes into the output stream.
Java Server Pages (JSPs) • <html> • <title>Demo a simple JSP program</title> • <body> • <% • out.print( “Hello world” ); • %> • </body></html>
Java Server Pages (JSPs) • Can run JSPs on your own computer, even without an Internet connection • Install tomcat (servlet/jsp engine)
Installing and running Tomcat • Download jakarta-tomcat-7.0.37 • Just unzip the file, no installation needed • Can unzip the file anywhere
Installing and running Tomcat • Find bin directory in jakarta-tomcat-7.0.37 directory • Edit the file startup.bat • SET JAVA_HOME = c:\…\jdk7 • // whatever your file path is for the java • // version installed on your computer
Installing and running Tomcat • From command line inside bin directory, start tomcat: • startup • // that should open another window … • // tomcat is running, you can run JSPs
Installing and running Tomcat • Open your browser and go to: • http://localhost:8080 • 8080 is the default port so make sure it is not taken by another program • If it is, you can change tomcat’s default port by editing server.xml
Installing and running Tomcat • Your browser ends up in jakarta-tomcat-7.0.37/webapps/ directory • From there, call a jsp file with the appropriate file path
Installing and running Tomcat • You should place your files in the webapps directory • To access heelo.jsp from a web browser: • http://leda.capitol-college.edu:8180/hfranceschi/hello.jsp