Once you have your WebLogic server set up, you can start development. Organizing your files into a directory structure will ease the development process. The following sections deal with the directory structure for different J2EE components' development. Directory Structure for Developing ServletsThe servlets that you create during the course of this book have to go into a directory called classes. The location of this classes directory, in case you wish to deploy it in an exploded format, is as follows: BEA_HOME\user_domains\mydomain\applications\ShoppingApp\WEB-INF\classes Here, ShoppingApp directory is the Web application directory. If you wish to use a WAR file instead, this WAR file will go directly under the applications directory in the path just shown. Note that the directory structure of the elements of the WAR file that you create should be as seen in Figure B.10: Figure B.10. Directory structure of a WAR file.For the example servlet applications, you first develop the code in directories exampleHiddenVar (servlet session maintenance with hidden variables), exampleURLRewriting (servlet session maintenance with URL rewriting), exampleCookie (servlet session maintenance with cookies), and exampleHttpSession (servlet session maintenance with HTTP session) all under the directory C:\book\code, which you compile into the directory C:\book\code\ShoppingApp\WEB-INF\classes. To make the process of development easier, create the following compile and run batch files. Note The compile file for the application using the examplesHiddenVar directory is shown in this appendix. For the other individual directories, change the directory indicated by APP_DIR to the directory of the application being developed. This compile file specifically is meant to be used when you are using a WAR file. In case you wish to deploy your application in an exploded format, remove the jar cv0f statement and all statements related to the WAR file. Then put in statements to save the whole ShoppingApp directory into the path %BEA_HOME%\user_domains\mydomain\applications. The sample compile.bat file is as follows: @echo on set BEA_HOME=C:\bea set APP_DIR=C:\book\code\exampleHiddenVar call %BEA_HOME%\user_domains\mydomain\setEnv set CLASSPATH=%CLASSPATH%;%BEA_HOME%\jdk131\lib\dt.jar; %BEA_HOME%\jdk131\lib\tools.jar; set CLASSPATH=%CLASSPATH%;.\ShoppingApp\WEB-INF\classes;.; cd %APP_DIR% javac -d C:\book\code\ShoppingApp\WEB-INF\classes *.java if errorlevel 1 goto DISCONTINUE cd.. del *.war jar -cv0f ShoppingApp.war del %BEA_HOME%\user_domains\mydomain\applications\ShoppingApp.war copy ShoppingApp.war %BEA_HOME%\user_domains\mydomain\applications :DISCONTINUE echo [ERROR] - cannot continue ENDLOCAL The sample run.bat file is as follows: set BEA_HOME=C:\bea cd %BEA_HOME%\user_domains\mydomain call startWebLogic Note Entering the user ID and password for your server in the startWebLogic.cmd file speeds up your development a little. However, this is not advisable in a production environment. Directory Structure for Developing JSPsThe JSPs are to be saved in the directory C:\book\code\JSP, which you have to create directly under the Web application directory. This is the document root directory, and any JSPs or HTML files should be saved in this directory. Directory Structure for Developing EJBsIn this book, the code for EJB applications is developed in the directories BMP, CMP, stateless, and stateful under the directory C:\book\code\EJB. The compiled EJB code is saved in the BEA_HOME\user_domains\mydomain\applications directory for hot deployment of the EJBs. Table B.1 gives an overview of the locations of the various kinds of components in your application.
|