Mr. Micheal ShoeMaker : Speaks about Softwares needed
|
To set up J2EE u need the following softwares
1. J2EE1.3.1 - j2sdkee-1_3_1-win.exe , download from sun site
2. J2SDK1.3.1 - j2sdk-1_3_1_09-windows-i586.exe , download from sun site
3. Oracle 9i Client Setup [Optional] unless ur using Oracle , download from oracle site
4. Macromedia HomeSite Editor[Optional]
|
Initial Environmental Configuration
|
Assumption 1 : Your Java SDK is installed in C:\jdk1.3.1
Assumption 2 : Your Java J2EE is installed in C:\j2sdkee1.3.1
Assumption 3 : Your Java Oracle Client is set in D:\oracle
Right Click on My Computer Go to Properties and Environmental Variables and add System Variables
1. Variable Name : JAVA_HOME :: value C:\jdk1.3.1
2. Variable Name : J2EE_HOME :: value C:\j2sdkee1.3.1
3. Variable Name : path :: value [otherpaths];d:\oracle\ora81\bin;C:\jdk1.3.1\bin;C:\j2sdkee1.3.1\bin
4. Variable Name : CLASSPATH :: value C:\j2sdkee1.3.1\lib\ejb10deployment.jar;C:\j2sdkee1.3.1\lib\j2ee.jar;
C:\j2sdkee1.3.1\lib\j2ee-ri-svc.jar;C:\j2sdkee1.3.1\lib\j2eetools.jar;
C:\j2sdkee1.3.1\lib\jhall.jar;D:\oracle\ora81\jdbc\lib\classes12.zip
5. Edit userconfig.bat in C:\j2sdkee1.3.1\bin Directory and add this line at Bottom
SET J2EE_CLASSPATH=D:\oracle\ora81\jdbc\lib\classes12.zip;
Re-Start Your System after u make change
|
TNSNAMES [To be used Only if u r using Oracle DB] : D:\oracle\ora81\network\ADMIN\tnsnames.ora
|
This is one of the most important files your Entry must look something like this
But PLEASE CONSULT YOUR ORACLE DBA while making changes in this file
EntryName =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle_host_server_name)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = service_name)
)
)
|
Starting J2EE Server and Deploytool
|
C:\>j2ee -verbose This will start the J2EE Server
C:\>j2ee -stop This will stop the J2EE Server
C:\>deploytool This will start the Java GUI Deploytool
|
Mr. Hen Fisherman Speaks about building/ Deploying Our First J2EE File
|
Step 1 : Create a Dir under E:\Phone u can however choose C or D: left to u i am using E:
Dir Structure
E:\Phone
--------\ear
--------\jsp
--------\sql
--------\java
--------\EJB
Later we can add more .. right now ear and jsp dir will be sufficient for us.
Step 2 : write a simple jsp file welcome.jsp and save it in E:\Phone\jsp dir , from now on all jsp files
will be stored here ..
<html>
<head>
<title>James Smith's Java : james_smith73@yahoo.com</title>
</head>
<body>
Welcome to James Smith's Java : james_smith73@yahoo.com <br><br>
:0)
</body>
</html>
|
|
I assume that u have already started J2EE Server and Deploytool. Click on File -> New Application
|
|
Select the Dir ear under Phone Directory , Click on New Application
|
|
You can see something like this
|
|
Observe the Right pane under General Tab where one can see many files created and not yet deployed
|
|
Highlight Phone Application in Left Pane and Add a Web Component
|
|
There will be a pop up window opening , click Next
Create a New WAR File Radio be selected .. name it as PhoneWAR
Click on Edit Button Below and Add our jsp/welcome.jsp file .
please note jsp folder must also be added .. very important
not just file
|
|
Click OK u can see the jsp folder and welcome.jsp file created in Contents Display area.
|
|
Click Next , Select JSP radio button as we will add JSP , then Click Next
|
|
select jsp/welcome.jsp from the pull down list , web component name be welcome
|
|
Init Params are global variables which are defined in xml file and can be directly
accessed by the JSP . i mean any jsp under the same war file . in our first example
we wont be using this but later we will. its a name = value pair of variables.
use ADD button to add more variables
|
|
Alias name is nothing but other name , to access the jsp page , much used when
ur jsp page is under many sub folders u can simply give a easy to access name rather
than giving a complete path , Click Finish Button
|
|
Now if u expand tree under left pane u can see many things under right pane . click on
Web Context Tab , type in WelcomeRoot this creates a folder named
WelcomeRoot under our local host server where all our jsp/classes/beans/html/js and other
files are put under relavent directories . to put in simple words its a folder name
used to access our work
|
|
Every thing is over . Click on Deploy Menu item under Tools Menu, Observe till
now under local host we have no deployments visible yet
|
|
Click Finish
|
|
u can see color test tubes :-) . let them fly . Observe the ear file deployed
under localhost server. encircled in red in the picture , click OK
|
|
you can Open your Internet explorer browser and type in
http://localhost:8000/WelcomeRoot/jsp/welcome.jsp
|
Or http://localhost:8000/WelcomeRoot/WelcomePage
Remember the Alias Name ??
|
When to Deploy and When to Redeploy ??
|
Adding of Any New file must be followed by Deploy under Tools menu
where as Update and Redeploy must be used when a certain file already deployed is modified
and u want to see a latest version uploaded
so let us modify our welcome.jsp a bit and save it in is original location of
E:\Phone\jsp ,
<html>
<head>
<title>James Smith's Java : james_smith73@yahoo.com</title>
</head>
<body>
Welcome to James Smith's Java : james_smith73@yahoo.com <br><br>
:-0) <br><br>
This is the First Chapter , Must be very easy ;-
</body>
</html>
This has to be followed by
YES
OK ,
now new page can be seen after refreshing the browser of pressing F5 Button in keyboard
|
Using Init Parameters
|
If u can recall the above screen . we had set up 2 varibles called Init params one was header and the variable
was named footer. [please see the above pics for init params]
now we will edit our local code welcome.jsp , to access these init params ,
<html>
<head>
<title>James Smith's Java : james_smith73@yahoo.com</title>
</head>
<body>
<%@ page import="java.sql.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<%!
ServletConfig cfg =null;
String header=null;
String footer=null;
public void jspInit()
{
cfg=getServletConfig();
header = cfg.getInitParameter("header") ;
footer = cfg.getInitParameter("footer") ;
}
%>
<br><%=header%><br><br>
This is Body<br><br>
<br><%=footer%><br><br>
</body>
</html>
Save, Update and Redeploy, and Refresh the Browser
|
web.xml worth a glance
|
In C:\j2sdkee1.3.1\public_html\WelcomeRoot\WEB-INF i can see web.xml file
i will just open using notepad to see what J2EE Deploytool has written there .
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<display-name>PhoneWAR</display-name>
<servlet>
<servlet-name>welcome</servlet-name>
<display-name>welcome</display-name>
<jsp-file>/jsp\welcome.jsp</jsp-file>
<init-param>
<param-name>header</param-name>
<param-value>---------- Welcome Page -------------</param-value>
</init-param>
<init-param>
<param-name>footer</param-name>
<param-value>--------- mail : james_smith73@yahoo.com</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>welcome</servlet-name>
<url-pattern>/WelcomePage</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
You can see where exactly Alias name and init params are written [variables and values]
|
What Next => Available : YES
|
Next Lesson will be given Mr. Peter Norton how to setup Cloudscape and Oracle to access
Database . Mr. Hen Fisherman will access that Data using JNDI
You have to mail me your ur Feedback its very important for me
to write more and keep interest on this chapter at james_smith73@yahoo.com
Join the group to be updated in case u are not the group member.
|
Reach me!
|
|
Java, J2EE, J2SE and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc.
in the United States and other countries.
|