Open source software security

Creating an Oracle .WAR file for deployment

30 November -0001
Sept. 26, 2003

This article assumes that you've got a .jsp only application (no beans or whatever) that you want to deploy via WAR file through the Oracle management web interface.

First thing to do is create a directory named after your application.

Next create a subdirectory in the directory called 'WEB-INF'. In this directory place a file called web.xml. Edit this file to look something like this:


<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/
dtds/web-app_2_2.dtd">


<web-app>


<servlet>
<servlet-name>login</servlet-name>
<jsp-file>login.jsp</jsp-file>
<servlet-name>footer</servlet-name>
<jsp-file>footer.jsp</jsp-file>

</servlet>

   <display-name>WhatEverNameYouWantDisplayed</display-name>


   	<description>
 replace this with a short description</description>
	<welcome-file-list>
      
		<welcome-file>login.jsp</welcome-file>
   
	</welcome-file-list>

   
</web-app>

Where each servlet-name item is the name of the .jsp page and the jsp-file item is the absolute path to the file (include subdirectories in the absolute path). An easy way to get a list of all the .jsp files so you can format them is to go to a command line, cd to the directory and issue (on Win2k):


dir /B *.jsp > ../yourlist.txt

where 'yourlist.txt' is a textfile for storing the names. If you want you can use the following VB code to quickly format up one of these lists (the form is pretty simple, two text inputs, one for the text file location, one for the prefixes (subdirectories) and an output text field, and a button to process it all):

[---------- Begin Snip ----------]


Private Sub Command1_Click()

Dim theName As String
theName = Text1.Text
Dim theLen As Integer


    Open theName For Input As #3
    
    While Not EOF(3)
    
        Line Input #3, sTemp
        theLen = Len(sTemp) - 4
        Text3.Text = Text3.Text & "<servlet-name>"
        Text3.Text = Text3.Text & Mid(sTemp, 1, theLen)
        Text3.Text = Text3.Text & "</servlet-name>" & vbCrLf
        Text3.Text = Text3.Text & "<jsp-file>" & Text2.Text & sTemp & "</jsp-file>" & vbCrLf
    
    Wend
    Close (3)
End Sub

[---------- Begin Snip ----------]

Next take the whole directory and put it somewhere you can remember. Then open up a command prompt or shell and cd to the directory location. Then create a Java archive with:

jar cvf myName.war *

where 'theName' is the name of the war you want and you're good to go.