160 likes | 510 Views
Web applications using Java and NetBeans. A very brief introduction with references to ASP.NET and Visual Studio. NetBeans IDE. NetBeans is an IDE Integrated Development Environment NetBeans supports development in a number of programming languages Java, C/C++, PHP, Ruby, etc.
E N D
Web applicationsusing Java and NetBeans A very brief introduction with references to ASP.NET and Visual Studio Web applications using Java and NetBeans
NetBeans IDE • NetBeans is an IDE • Integrated Development Environment • NetBeans supports development in a number of programming languages • Java, C/C++, PHP, Ruby, etc. • NetBeans is a Java application • NetBeans runs under a number of operation systems • Windows, Linux, Mac OS, etc. • http://netbeans.org/index.html Web applications using Java and NetBeans
Apache Tomcat • Apache Tomcat is a web server • Open Source • Runs Java Servlets and JSP, etc. • Normally uses port 8080 if run from NetBeans • Included with NetBeans (some editions) • Can be downloaded separately • http://tomcat.apache.org/ Web applications using Java and NetBeans
GlassFish • GlassFish is a Java application server • Open Source + commercial (Oracle GlassFish) • Runs Java Servlets, JSP and a lot more • Implements the full J2EE • Included with NetBeans (some editions) • http://glassfish.java.net/ Web applications using Java and NetBeans
Java vs. C# • The Java Programming Language and C# are quite similar in syntax and semantics • Both are object-oriented • Both belong to the curly-brace family of programming languages • Java is older than C# • Java has fewer keywords than C# Web applications using Java and NetBeans
Java Servlets and JSP • Java offers two ways to make web applications • Java Servlets • Java code with HTML inside • JSP (JavaServer Pages) • HTML with Java code inside • Servlets and JSP are often/best used in combination • Servlets and JSP are part of Java Enterprise Edition • Features to be run by a web or application server Web applications using Java and NetBeans
Post back to other pages • With ASP.NET the normal post back is to the same page • With Java you specify the page to post to • <form action="welcome.jsp> Web applications using Java and NetBeans
HTTP POST vs. GET methods • The HTTP protocol offers two way to send data from a form to the server • POST • Data is carried in the body of the request • <form action="welcome.jsp" method="POST“ > • GET • Data is carried in the request URL • http://localhost:8084/firstwebapp/welcome.jsp?username=Anders&password=secret • Default in Java • Good for debugging • Easy to see data Web applications using Java and NetBeans
Picture from http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/app-arch/app-arch2.html Model-View-Controller (MVC) in general Web applications using Java and NetBeans
Model-View-Controller in Java web-applications • Model • Java Bean • View • JSP • Controller • Servlet • Picture from • http://janaudy.com/j2ee-labs/4-JSP-Servlets-MVC/jsp-servlets-mvc_en.htm Web applications using Java and NetBeans
Model-view-controller in ASP.NET web-applications • ASP.NET MVC is similar to MVC Java web-applications • ASP.NET MVC is quite different from ASP.NET Web Forms • http://www.asp.net/mvc Web applications using Java and NetBeans
No ViewState in JSP/Servlets • ASP.NET has ViewState • With JSP/Servlets there is nothing like ViewState Web applications using Java and NetBeans
Deploying a Java web application • When you build a web application you get a WAR file • Web Archive • Essentially a ZIP file • Holds all necessary parts of the web application • Can be copied to the production web server • Tomcat: the folder webapps/ • Tomcat: bin/startup.bat, bin/shutdown.bat • Tomcat normally runs on port 8080 Web applications using Java and NetBeans
Java web frameworks • Apache Struts • MVC framework • http://struts.apache.org/ • JSF (JavaServer Faces) • Another MVC framework • http://www.javaserverfaces.org/ • Facelets • View generation framework • Alternative to JSP • http://facelets.java.net/ • http://download.oracle.com/javaee/6/tutorial/doc/giepx.html • Hibernate • An ORM (Object/Relational Mapping) • Connects an object oriented programming language (Java or .NET) with a relational DBMS • http://www.hibernate.org/ • If you want to compare ASP.NET + Visual Studio to Java web applications + NetBeans please take the frameworks into consideration Web applications using Java and NetBeans
Further readings, etc. • Marty Hall Core Servlets and JavaServer Pages Volume 1 + 2, Prentice Hall 2008 • Older edition (2002) called More Servlets and JavaServer Pages available on http://pdf.moreservlets.com/ • NetBeans.org Java EE & Java Web Learning Trail • http://netbeans.org/kb/trails/java-ee.html • Specially Introduction to Developing Web Applications • http://netbeans.org/kb/docs/web/quickstart-webapps.html • YouTube Java Servlet Definition (video 3:44) • http://www.youtube.com/watch?v=Y1-JvAC9tlM • The Java EE 6 Tutorial • Chapter 10 Java Servlet Technology • http://download.oracle.com/javaee/6/tutorial/doc/bnafd.html • ApacheTomcat download and documentation • http://tomcat.apache.org/ Web applications using Java and NetBeans