enterprise net beans & j2ee tutorials

netbeans tutorial on netbeans.org website :

hello world app in the netbeans ide

web applications tutorial

:::

J2EE tutorials

XML
JAXP = java xml api (processing)
- dom - reads xml & creates a tree of tags
- sax - simple api for xml - read a stream of tags

JAXB = java api for xml binding

JAXR = java api for xml registry
- registry is used to deploy & locate web services
- jaxr is the abstraction that makes the interface to the web services look the same

JAXM = java api for xml messaging
- send and receive xml documents as messages
- includes SOAP (message format)

transactions
- to record the state of different steps in the application process
- useful to help keep track of what's happening eg if a system crashes at one of the stages
eg transfer $100 from one account to another
- EJB can be used to manage transactions

http://www.sun.com website - get latest version
j2re = runtime edition. has enough / minimum you need to run java apps
j2se = standard edition. if you're going to write apps you need this one. contains j2re
j2ee = enterprise edition. contains j2se & j2re. download either as 1 bundle, or as 4 separate parts (j2se, java application server, j2ee examples, j2ee documentation)

configuration
- Administration username = Admin
- administration port = 4848 (default - can use another port)
- http port=8080, https port=8081 (default values - can change these)
- path - add the paths to your PATH : eg (default) c:\Sun\AppServer;c:\Sun\AppServer\bin;c:\Sun\AppServer\jdk;c:\Sun\AppServer\jdk\bin

start
start server (windows machine) :
- program files - sun microsystems - application server - start default server
- open http://localhost:8080 & see the default page

start pointbase database
- program files - sun microsystems - application server - start pointbase
- relational database on the windows machine

jsp file
- is an html file with java code in it
- use one type of tag throughout the file eg '%' or 'jsp:' not a mix of both
- scripting code : < % --code here-- % > (remove spaces), or < jsp:scriptlet > ... < /jsp:scriptlet > (remove spaces)
- declarative code : < %! --code here-- % > or < jsp:declaration > ... < /jsp:declaration > (remove spaces) - like a global variable - inside the class definition but outside the method (eg code you write yourself)
- expression : evaluted as a string to display as text : < %= --code here-- % > or < jsp:expression > ... < /%jsp:expression > (remove spaces)
- comment code : < !-- html comment -- > or < %-- jsp comment --% > (remove spaces)
- directive code : < %@ page ... % > or < jsp:directive.page ... / > eg < %@ include file="footerl.incl" % > (remove spaces)

deploy tool - server gui
- this uses administration port 4848
- to create the .war file (web archive)

api
- docs
- on the server, file:///c:/Sun/AppServer/docs/api/index.html

create war file - from dos prompt
eg : outloop.jsp file & WEB-INF dir with web.xml file

jar cvf newwarfile.war dir1 file1
jar cvf second.war WEB-INF outloop.jsp

deploy a jsp page
- via admin webpage:
- open http://localhost:4848/asadmin
- this opens an admin page
- login using admin/pwd

api - java.lang.Object
out object
- eg java.io.writer
- .request & .response objects
page object
application object
config object
pageContext object

page directive
- these 3 are always imported with generated code
import javax.servlet.*;
import javax.servlet.jsp.*;
import javax.servlet.http.*;
- you could import others eg < %@ page import="java.util.Vector,java.awt.*" % > (remove spaces)
- java.lang always = java so no need to import (default value)
- put these at the top of file so they're before the imported class is used / called

- if you want to use a session object for every user of the page (default session="true"), or if you don't want to use sessions, then use : < %@ page session="false" % >
- eg if you don't want to use cookies or generate separate sessions

- info - this can be called from within the jsp page eg < %@ page info="this line of text" % >
- it can be called by using : Servlet.getServletInfo()

- errorPage - use this to specify the error page to display : < %@ page errorPage="url" % >

tag library : http://java.sun.com/j2ee/dtds/web-jsptaglib_1_1.dtd (page not found - this is prob an old version)

packages
package directory names & package names (.java files) :
com.vtc.howdy.java

compilation
compile : java file -> class
javac -classpath "c:\Sun\AppServer\lib\j2ee.jar" myfile.jar

tag libraries
- make common files if you want to reuse these in multiple files
- there's common ones eg :
- JSTL (JSP standard tag library) @ http://jakarta.apache.org/taglibs
- can be used for standard tags for date & time, internationalisation, string manipulation, input & output etc
- you can add these to your project : put the .jar files in the WIN-INF: .jar files in lib dir, .tld files in the war file, then write the jsp page that uses the tags. documentation for each library tells you where to put the files etc

server examples
- example files on the server @ http://localhost:8080/standard-examples
- this path seems to be different on the new versions (glassfish server)

:::

servlet

- write a class that extends the HttpServlet class & overrides the default methods that come from the browser (compiled java code with http code inside it)

- GET
- POST
- PUT
- HEAD - just return the header
- DELETE
- TRACE
- OPTIONS - conversations between client & server

- deploy servlet in the admin console ---> web applications - deploy - choose .war file

filter
- used for things such as : authenticating a user, logging, compressing / decompressing data, encrypting / decrypting data to & from browser. the example just changed the background colour of the html page (very simple example)

MVC
- model view controller
- design approach
- PAC - presentation abstraction controller ---> another 3 tiered architecture

database
- drivers : type 1 - type 4
- download from : http://industry.java.sun.com/products/drivers (old link)

web services
- list of publicly available web services : http://www.xmethods.net

====================

Java EE 5 SDK Update 7

Netbeans docs

http post clients
apache http post example

sun java http post

::: location: