I am absolutely perplexxed


A

A. Name

Someone please help me. This servlet is working when deployed in
tomcat in IE, but not in Netscape

// import java libraries
import java.io.*;
import java.util.*;
import java.lang.*;

// import servlet libraries
import javax.servlet.*;
import javax.servlet.http.*;

// servlet implementation of Photo Personal Web Application Service
public class jopackiH8 extends HttpServlet {

// globals settings
private static String pathToAccount =
"../../../../../../../home/student/jopacki/public_html/";
private boolean isTrue = true;
private boolean errTrue = false;
private String errorMsg = "";

// begin doGet process to return initial web form
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
response.setContentType ("text/html");
PrintWriter out = response.getWriter();

out.println("<!--- Joseph Opacki, SWE432, Fall 2003 --->");
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">");
out.println("<html>");
out.println(" <head>");
out.println(" <title>Photo Personal Web Application
Service</title>");
out.println(" <style type=\"text/css\">");
out.println(" body, p, td ");
out.println(" {");
out.println(" font-size: 12px;");
out.println(" font-family: Arial, Helvetica, sans-serif;");
out.println(" }");
out.println("");
out.println(" .title ");
out.println(" {");
out.println(" font-size: 18px;");
out.println(" color: white;");
out.println(" font-weight: bold;");
out.println(" padding-bottom: 10px;");
out.println(" padding-top: 10px;");
out.println(" }");
out.println("");
out.println(" .subtitle");
out.println(" {");
out.println(" font-size: 14px;");
out.println(" color: black;");
out.println(" font-weight: bold;");
out.println(" padding-bottom: 2px;");
out.println(" padding-top: 2px;");
out.println(" }");
out.println(" </style>");
out.println(" <script LANGUAGE=\"JavaScript\">");
out.println(" // my testing in Mozilla has been kind of buggy. Only
worked half of the time");
out.println(" // I've achieved my best results in IE");
out.println("");
out.println(" /* ************************************************
/");
out.println(" / Browser dection to be used throughout javascript /");
out.println(" / *************************************************
*/");
out.println(" isMac = (navigator.appVersion.indexOf(\"Mac\")!= -1) ?
true : false");
out.println(" NS4 = (document.layers) ? true : false");
out.println(" IEmac = ((document.all)&&(isMac)) ? true : false");
out.println(" IE4plus = (document.all) ? true : false");
out.println(" IE4 =
((document.all)&&(navigator.appVersion.indexOf(\"MSIE 4.\") != -1)) ?
true : false");
out.println(" IE5 =
((document.all)&&(navigator.appVersion.indexOf(\"MSIE 5.\") != -1)) ?
true : false");
out.println(" ver4 = (NS4 || IE4plus) ? true : false");
out.println(" NS6 = (!document.layers) &&
(navigator.userAgent.indexOf('Netscape') != -1)?true:false");
out.println("");
out.println(" /* *********************************************************
/");
out.println(" / Body onload utility (supports multiple onload
functions) /");
out.println(" / *********************************************************
*/");
out.println(" var gSafeOnload = new Array()");
out.println(" function SafeAddOnload(f)");
out.println(" {");
out.println(" if (IEmac && IE4) // IE 4.5 blows out on testing
window.onload");
out.println(" {");
out.println(" window.onload = SafeOnload");
out.println(" gSafeOnload[gSafeOnload.length] = f");
out.println(" } else if (window.onload)");
out.println(" {");
out.println(" if (window.onload != SafeOnload)");
out.println(" {");
out.println(" gSafeOnload[0] = window.onload");
out.println(" window.onload = SafeOnload");
out.println(" }");
out.println(" gSafeOnload[gSafeOnload.length] = f");
out.println(" } else");
out.println(" {");
out.println(" window.onload = f");
out.println(" }");
out.println(" }");
out.println("");
out.println(" function SafeOnload()");
out.println(" {");
out.println(" for (var i = 0; i < gSafeOnload.length; i++)");
out.println(" {");
out.println(" gSafeOnload()");
out.println(" }");
out.println(" }");
out.println("");
out.println(" /* ***************************** /");
out.println(" / Main Dynamic Form Functions /");
out.println(" / ***************************** */");
out.println("");
out.println(" // these arrays holds our form values when we need to
regenerate the forms");
out.println(" var photoURLFieldValues = new Array(1)");
out.println(" var photoCaptionFieldValues = new Array(1)");
out.println("");
out.println(" for (var i = 0; i < photoURLFieldValues.length; i++)");
out.println(" {");
out.println(" // the length of these two fields should always be the
same");
out.println(" photoURLFieldValues = \"\"");
out.println(" photoCaptionFieldValues = \"\"");
out.println(" }");
out.println("");
out.println(" function GetFormHTML()");
out.println(" {");
out.println(" var htmlStr = ''");
out.println(" htmlStr += '<table width=\"100%\">'");
out.println("");
out.println(" for (var i = 0; i < photoURLFieldValues.length; i++)
// the length of both should always be the same");
out.println(" {");
out.println(" htmlStr += '<tr><td width=\"15\"><b>' + (i+1) +
'</b></td><td align=\"right\" valign=\"top\"><input type=\"text\"
name=\"photoURL\" size=\"50\" maxlength=\"250\" title=\"Use this form
to input the location of your photo.\" value=\"' +
photoURLFieldValues + '\"></td><td>&nbsp;</td><td
align=\"left\"><input type=\"text\" name=\"photoCaption\" size=\"50\"
title=\"Use this form to enter the catption information for your
photo.\" value=\"' + photoCaptionFieldValues + '\"></td></tr>'");
out.println(" }");
out.println("");
out.println(" htmlStr += '</table>'");
out.println("");
out.println(" return htmlStr");
out.println(" }");
out.println("");
out.println(" function GetFormObj()");
out.println(" {");
out.println(" var returnObj = null");
out.println("");
out.println(" if (NS4)");
out.println(" {");
out.println(" returnObj = document.formlayer.document.pwasEntry");
out.println(" }");
out.println(" else if (NS6)");
out.println(" {");
out.println(" returnObj =
document.getElementById(\"pwasEntry\")");
out.println(" } else");
out.println(" {");
out.println(" returnObj = document.pwasEntry");
out.println(" }");
out.println(" return returnObj");
out.println(" }");
out.println("");
out.println(" function AddField()");
out.println(" {");
out.println(" // Save previously entered data here");
out.println(" var formObj = GetFormObj()");
out.println("");
out.println(" for (var i = 0;i < photoURLFieldValues.length; i++)");
out.println(" {");
out.println(" if (photoURLFieldValues.length > 1)");
out.println(" {");
out.println(" photoCaptionFieldValues=
formObj.photoCaption.value");
out.println(" photoURLFieldValues= formObj.photoURL.value");
out.println(" } else ");
out.println(" {");
out.println(" photoCaptionFieldValues =
formObj.photoCaption.value");
out.println(" photoURLFieldValues= formObj.photoURL.value");
out.println(" }");
out.println(" }");
out.println("");
out.println(" // activate default index image if first time adding
image");
out.println(" // only set it to default if there is no image already
there");
out.println(" if (document.forms[0].indexImage.value == \"\")");
out.println(" {");
out.println(" document.forms[0].indexImage.value =
photoURLFieldValues[0]");
out.println(" }");
out.println("");
out.println(" // Create the new field");
out.println(" photoURLFieldValues[photoURLFieldValues.length]=\"\"");
out.println(" photoCaptionFieldValues[photoCaptionFieldValues.length]=\"\"");
out.println("");
out.println(" UpdateForm()");
out.println(" }");
out.println("");
out.println(" function UpdateForm()");
out.println(" {");
out.println(" var htmlStr = GetFormHTML()");
out.println(" if (IE4plus)");
out.println(" {");
out.println(" document.all.formlayer.innerHTML = htmlStr");
out.println(" } else if (NS4)");
out.println(" {");
out.println(" document.formlayer.document.open()");
out.println(" document.formlayer.document.write(htmlStr)");
out.println(" document.formlayer.document.close()");
out.println(" } else // should cover NS5 and NS6 and Mozilla ");
out.println(" { ");
out.println(" document.getElementById(\"formlayer\").innerHTML =
htmlStr");
out.println(" } ");
out.println(" }");
out.println("");
out.println(" function IncludeForm()");
out.println(" {");
out.println(" var htmlStr = GetFormHTML()");
out.println("");
out.println(" if (IE4plus || NS6)");
out.println(" {");
out.println(" document.write('<DIV ID=formlayer name=formlayer
STYLE=\"position:relative; WIDTH=400px; HEIGHT=50px\">' + htmlStr +
'</DIV>');");
out.println(" }");
out.println(" else if (NS4)");
out.println(" {");
out.println(" // Because NS needs floating layers, we need a
placeholder graphic to force anything");
out.println(" // below the layer content to leave whitespace for
the layer. The position of this");
out.println(" // graphic is also used in determining the position
of the layer.");
out.println(" document.write('<img name=\"formlocation\"
border=\"0\" width=\"100%\" height=\"100%\" src=\"clear.gif\">')");
out.println(" }");
out.println("");
out.println(" }");
out.println("");
out.println(" //");
out.println(" // Netscape 4.x ");
out.println(" //");
out.println(" function HandleOnload()");
out.println(" {");
out.println(" if (NS4)");
out.println(" {");
out.println(" var width = document.formlocation.width");
out.println(" var height = document.formlocation.height");
out.println("");
out.println(" nL=new Layer(width)");
out.println(" nL.name = \"formlayer\"");
out.println(" nL.left=document.formlocation.x");
out.println(" nL.top=document.formlocation.y");
out.println(" nL.bgColor = \"white\"");
out.println(" nL.clip.width=width");
out.println(" nL.clip.height=height");
out.println(" nL.document.open()");
out.println(" nL.document.write(GetFormHTML())");
out.println(" nL.document.close()");
out.println(" nL.visibility = 'show'");
out.println(" document.formlayer = nL");
out.println(" }");
out.println(" }");
out.println("");
out.println(" function HandleResize()");
out.println(" {");
out.println(" location.reload()");
out.println(" return false");
out.println(" }");
out.println("");
out.println(" if (NS4)");
out.println(" {");
out.println(" SafeAddOnload(HandleOnload)");
out.println(" window.captureEvents(Event.RESIZE)");
out.println(" window.onresize = HandleResize");
out.println(" }");
out.println(" </script>");
out.println(" </head>");
out.println(" <body>");
out.println(" <div align=\"center\">");
out.println(" <form action=\"jopackiH8\" method=\"post\"
name=\"pwasEntry\" id=\"pwasEntry\">");
out.println(" <table width=\"95%\" border=\"0\" cellspacing=\"0\"
cellpadding=\"10\" bgcolor=\"#f5f5f5\">");
out.println(" <tr bgcolor=\"#4682b4\">");
out.println(" <td align=\"center\" valign=\"middle\"
class=\"title\">");
out.println(" Photo Personal Web Application Service");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td>");
out.println(" <strong>Application description and
instructions</strong><br>");
out.println(" This application was created by <a
href=\"mailto:[email protected]\">Joseph Opacki</a> for SWE432 in the
Fall 2004 semester at George Mason University. The code to create
this servlet can be ");
out.println(" accessed at <a
href=\"http://hermes.gmu.edu/~jopacki/jopackiH8.java\">http://hermes.gmu.edu/~jopacki/jopackiH8.java</a>.
Please step through each of the sections below and follow the
instructions in each section ");
out.println(" to create a photographic gallery using Java
servlets.");

// print out the errors if returned to this page with errors
if ( errTrue )
{
out.println("<p><font color=\"RED\"><strong>The following problems
have been detected:</strong><br>");
out.println( errorMsg );
// reset values for next submit
errorMsg = "";
errTrue = false;
}

out.println(" </td>");
out.println(" </tr>");
out.println(" <tr bgcolor=\"#b0c4de\">");
out.println(" <td class=\"subtitle\">");
out.println(" Photographic Collection");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td>");
out.println(" <strong>Section Description and
Instructions</strong><br>");
out.println(" Fill in the blanks in the following field being
careful not to leave any of them blank.");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td align=\"center\" valign=\"top\">");
out.println(" <table width=\"540\">");
out.println(" <tr>");
out.println(" <td align=\"right\" nowrap
width=\"100\">Collection Name:</td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td align=\"left\">");
out.println(" <input type=\"text\" name=\"collectionName\"
size=\"50\" maxlength=\"250\" title=\"Use this input field to input a
title for your collection of photographs.\">");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td align=\"right\"
valign=\"top\">Description:</td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td align=\"left\">");
out.println(" <textarea cols=\"50\" rows=\"3\"
name=\"collectionDescription\" title=\"Use this form to describe the
overall collection of photographs that your are
entering.\"></textarea>");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td align=\"right\" valign=\"top\"
nowrap>Background Color:</td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td align=\"left\">");
out.println(" <input type=\"text\" name=\"backgroundColor\"
size=\"50\" maxlength=\"6\" title=\"Use this form to input what color
you wish to have represented for the background throughout your
collection of photographs.\"><br>");
out.println(" <span style=\"color: SteelBlue;\">There is no
need to include the <strong>#</strong> sign in your entry.</span>");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td align=\"right\" nowrap width=\"100\"
valign=\"top\">Index Image:</td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td align=\"left\">");
out.println(" <input type=\"text\" name=\"indexImage\"
size=\"50\" maxlength=\"250\" title=\"Use this form to place an index
image on the entrance page of your photographic collection.\"><br>");
outprintln(" <span style=\"color: SteelBlue;\">The index
image will default to your first photo if you do not choose
one.</span>");
out.println(" </td>");
out.println(" </tr>");
out.println(" </table>");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr bgcolor=\"#b0c4de\">");
out.println(" <td class=\"subtitle\">");
out.println(" Individual Photos");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td>");
out.println(" <strong>Section Description and
Instructions</strong><br>");
out.println(" <font color=\"red\">Please note that you must
enter at least two photographs for this application to work
correctly.");
out.println(" </font> Start by entering the URL location of
each of your photographs followed by a small caption. When ready,
click the button to add a new row.");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td align=\"center\" valign=\"top\">");
out.println(" <table width=\"540\">");
out.println(" <tr>");
out.println(" <td align=\"left\" nowrap
width=\"49%\"><strong>Photo Location</strong></td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td align=\"left\"><strong>Photo
Caption</strong></td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td colspan=\"3\">");
out.println(" <script LANGUAGE=\"JavaScript\">");
out.println(" IncludeForm();");
out.println(" </script>");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td colspan=\"3\">");
out.println(" <table width=\"95%\">");
out.println(" <tr>");
out.println(" <td align=\"right\" valign=\"top\"><input
type=\"button\" value=\"Add Another\" onClick=\"AddField()\"></td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td align=\"left\">");
out.println(" Click the \"Add\" button to add new photos
to your repository. The list in your current repository will list
below with each photograph's information.");
out.println(" <span style=\"color: SteelBlue;\">You may
continue to add photos until you are ready to finalize your
collection.</span>");
out.println(" </td>");
out.println(" </tr>");
out.println(" </table>");
out.println(" </td>");
out.println(" </tr>");
out.println(" </table>");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr bgcolor=\"#b0c4de\">");
out.println(" <td class=\"subtitle\">");
out.println(" Finish Process and Create Collection");
out.println(" </td>");
out.println(" </tr>");
out.println(" <tr>");
out.println(" <td align=\"center\">");
out.println(" <table width=\"95%\">");
out.println(" <tr>");
out.println(" <td>Once you are satisfied with the number of
photo in your repository, then click on the upload collection button
below to upload your selections and create your photographic
collection.</td>");
out.println(" <td>&nbsp;</td>");
out.println(" <td><input type=\"submit\" name=\"Submit\"
value=\"Create Photographic Collection\"></td>");
out.println(" </tr>");
out.println(" </table>");
out.println(" </td>");
out.println(" </tr>");
out.println(" </table>");
out.println(" </form>");
out.println(" </div>");
out.println("<p><small>This application was created by Joseph Opacki
for SWE432 in Fall 2003 as HW8.</small></p>");
out.println(" </body>");
out.println("</html>");
out.close();
} // end doGet process

// begin doPost operation
public void doPost (HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException
{
// this is where all the magic happens
response.setContentType ("text/html");
PrintWriter out = response.getWriter ();

// get form values
String backgroundColor =
request.getParameter("backgroundColor").trim();
String indexImage = request.getParameter("indexImage").trim();
String collectionDescription =
request.getParameter("collectionDescription").trim();
String collectionName =
request.getParameter("collectionName").trim();
String[] photoCaption = request.getParameterValues("photoCaption");
String[] photoURL = request.getParameterValues("photoURL");
String[] photoFiles = new String [photoURL.length];

// ERROR CHECKING
// check collection name
if ( collectionName.length() == 0 || collectionName == null )
{
isTrue = false;
errorMsg += "You must enter a value for the <strong>collection
name</strong>.<br>";
}

// check collection description
if ( collectionDescription.length() == 0 || collectionDescription ==
null )
{
isTrue = false;
errorMsg += "You must enter a value for the <strong>collection
description</strong>.<br>";
}

// check backgound color
if ( backgroundColor.length() == 0 || backgroundColor == null )
{
isTrue = false;
errorMsg += "You must enter a value for the <strong>background
color</strong>.<br>";
}

// check background color field length
backgroundColor = backgroundColor.toUpperCase();
String validColor = "0123456789ABCDEF";

if ( backgroundColor.length() != 6 )
{
isTrue = false;
errorMsg += "Please verify that your <strong>background
color</strong> is at least six character long.<br>";
}

// check background color for validity
StringBuffer newBG = new StringBuffer(backgroundColor);
// just loop through the length of background color instead of six
// just in case they don't enter a long enough value.
for (int i = 0; i < backgroundColor.length(); i++ )
{
char currentPos = newBG.charAt(i);
// compare each char to validColor array
if (validColor.indexOf(currentPos) == -1)
{
isTrue = false;
errorMsg += "Please verify that you have used a valid background
color.<br>";
break;
}
}

// check index image
if ( indexImage.length() == 0 || indexImage == null )
{
// if blank, set a value so we don't get index out of range error
indexImage = "1234567890";
isTrue = false;
errorMsg += "You must enter a value for the <strong>index
image</strong>.<br>";
}

// check index image for valid url syntax
String checkIndexString = indexImage.substring(0,7);
if ( !checkIndexString.equals("http://") )
{
isTrue = false;
errorMsg += "The value for your <strong>index image</strong> does
not appear to be a syntactically correct URL.<br>";
}

// check to make sure that there are at least two rows of photographs
if ( photoURL.length <= 1 )
{
isTrue = false;
errorMsg += "Your submission must contain at least
<strong>two</strong> photographs with captions to be completed.<br>";
} else // there are at least two rows
{
// check to make sure photoURL and photoCaption are not blank
entities
for ( int i = 0; i < photoURL.length; i++ )
{
// trim all array values
photoURL = photoURL.trim();
photoCaption = photoCaption.trim();

// lowercase all URL array values
photoURL = photoURL.toLowerCase();

// set up current row
int currentRow = i + 1;

// first check each value of photoURL
if ( photoURL.length() == 0 || photoURL == null )
{
// if blank, set a value so we don't get index out of range error
photoURL = "1234567890";
isTrue = false;
errorMsg += "No value was detected for your <strong>photo
location</strong> in row number " + currentRow + ".<br>";
}

// check for valid URL syntax
String checkURL = photoURL;
String checkString = checkURL.substring(0,7);

// set up current row
if ( !checkString.equals("http://") )
{
isTrue = false;
errorMsg += "The value for your <strong>photo location</strong> in
row number " + currentRow + " does not appear to be a syntactically
correct URL.<br>";
}

// then chech each value of photoCaption
if ( photoCaption.length() == 0 || photoCaption == null )
{
isTrue = false;
errorMsg += "No value was detected for your <strong>photo
caption</strong> in row number " + currentRow + ".<br>";
}
}
}

// error checking complete, either doGet or continue posting
if (isTrue)
{
String inString;

// loop through each photoURL and get photoFile
for (int i = 0; i < photoURL.length; i++ )
{
// inString is now the full URL
inString = photoURL;

// Read the names into photoFiles
int len = inString.length();

// minusPeriod is the position right before the last period
// leaving off the extension of the URL
int minusPeriod = len - 4;

// initialize slash
int slash = 0;

// slash will be rewritten until its final value is the last /
for (int x = 0; x < len; x++)
{
char currentPos = inString.charAt(x);

if ( currentPos == '/' )
{
slash = x + 1;
}
}

// set photoFiles equal to the value between the last forward-slash
// and the period.extension of the URL
photoFiles = inString.substring(slash, minusPeriod);
}

// write the response
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">");
out.println("<!--- Joseph Opacki, SWE432, Fall 2003 --->");
out.println("<html>");
out.println("<head>");
out.println(" <title>Joseph Opacki - SWE432: HomeWork 8</title>");
out.println("</head>");
out.println("");
out.println("<body>");
out.println("<h2>Congratulations!</h2>");
out.println("");
out.println("<p>You can view your photo gallery at: <a
href=\"http://hermes.gmu.edu/~jopacki/index.html\">http://hermes.gmu.edu/~jopacki/index.html</a></p>");
out.println("");
out.println("<p>Your information has been parsed successfully and is
your photo gallery has been created with the following
information:</p>");
out.println("<p><blockquote>");
out.println(" <strong>Collection Name: </strong>" + collectionName
+ "<br>");
out.println(" <strong>Collection Description: </strong> " +
collectionDescription + "<br>");
out.println(" <strong>Background Color: </strong><font color=\"" +
backgroundColor + "\">" + backgroundColor + "</font><br>");
out.println(" <strong>Index Image: </strong> " + indexImage +
"<br>");

for ( int i = 0; i < photoURL.length; i++ )
{
int currentRow = i + 1;
out.println(" <strong>Photo Location " + currentRow + ": </strong>"
+ photoURL + "<br>");
out.println(" <strong>Photo Caption " + currentRow + ": </strong>"
+ photoCaption + "<br>");
}
out.println("</blockquote></p>");
out.println("");
out.println("<p>This application was created by Joseph Opacki for
SWE432, Fall 2003.</p>");
out.println("");
out.println("</body>");
out.println("</html>");

// write the index file
WriteIndex (backgroundColor, indexImage, collectionDescription,
collectionName, photoCaption, photoURL, photoFiles);

// write the photo files, one per picture
int NumFiles = photoURL.length;

WriteOneHTML ("", photoFiles[0], photoFiles[1], photoCaption[0],
photoURL[0], backgroundColor, collectionName);

for (int i = 1; i < NumFiles-1; i++)
{
WriteOneHTML (photoFiles[i-1], photoFiles, photoFiles[i+1],
photoCaption, photoURL, backgroundColor, collectionName);
}

WriteOneHTML (photoFiles[NumFiles-2], photoFiles[NumFiles-1], "",
photoCaption[NumFiles-1], photoURL[NumFiles-1], backgroundColor,
collectionName);

} else
{
// set up error status and send back
errorMsg += "</font></p>";
errTrue = true;
doGet(request, response);
}

out.close();
} //end of doPost()

// creates an index page for all photos
public static void WriteIndex (String backgroundColor, String
indexImage, String collectionDescription, String collectionName,
String photoCaption[], String photoURL[], String photoFiles[])
throws IOException
{
FileWriter newOut = new FileWriter (pathToAccount + "index.html");

newOut.write ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n");
newOut.write ("<html>\n");
newOut.write ("<head>\n");
newOut.write (" <title>" + collectionName + "</title>\n");
newOut.write ("</head>\n");
newOut.write ("\n");
newOut.write ("<body bgcolor=\"" + backgroundColor + "\">\n");
newOut.write ("<div align=\"center\">\n");
newOut.write (" <h2>"+ collectionName +"</h2>\n");
newOut.write ("\n");
newOut.write ("<table width=\"95%\">\n");
newOut.write (" <tr>\n");
newOut.write (" <td valign=\"top\" nowrap>\n");
newOut.write (" <ol>\n");
for (int i = 0; i < photoFiles.length; i++)
{
newOut.write (" <li><a href=\"" + photoFiles +".html\">" +
photoCaption + "</a>\n");
}
newOut.write (" </ol>\n");
newOut.write (" </td>\n");
newOut.write ("\n");
newOut.write (" <td valign=\"top\">\n");
newOut.write (" <p>" + collectionDescription + "</p><p
align=\"center\"><img src=\"" + indexImage + "\" height=200></p>\n");
newOut.write (" </td>\n");
newOut.write (" </tr>\n");
newOut.write ("</table>\n");
newOut.write ("</div>\n");
newOut.write ("<p><small>This application was created by Joseph
Opacki for SWE432 in Fall 2003 as HW8.</small></p>");
newOut.write ("</body>\n");
newOut.write ("</html>\n");
newOut.write ("\n");

newOut.close ();
} // end WriteIndex

// creates an html page for each photo
public static void WriteOneHTML (String prev, String cur, String
next, String title, String photoLocation, String backgroundColor,
String collectionName)
throws IOException
{
FileWriter fout = new FileWriter (pathToAccount + cur +".html");

fout.write ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">\n");
fout.write ("<html>\n");
fout.write ("<head>\n");
fout.write (" <title>" + cur + "</title>\n");
fout.write ("</head>\n");
fout.write ("\n");
fout.write ("<body bgcolor=\"" + backgroundColor + "\">\n");
fout.write ("<div align=\"center\">\n");
fout.write ("<p>\n");
fout.write ("<img src=\"" + photoLocation + "\" height=\"450\"
alt=\"" + cur + "\">\n");
fout.write ("\n");
fout.write ("<p>\n");
fout.write (title);
fout.write ("<br><i>" + collectionName + "</i><p>\n");
if (prev.length() != 0)
{
fout.write ("<A HREF=\"" + prev + ".html\">Previous</A> || \n");
} else
{
fout.write ("Previous || \n");
}

fout.write ("<a href=\"index.html\">Index</a>\n");

if (next.length() != 0)
{
fout.write (" || <A HREF=\"" + next + ".html\">Next</A>\n");
} else
{
fout.write (" || Next\n");
}
fout.write ("</p></div>\n");
fout.write ("<p><small>This application was created by Joseph Opacki
for SWE432 in Fall 2003 as HW8.</small></p>");
fout.write ("</body>\n");
fout.write ("</html>\n");
fout.write ("\n");

fout.close ();
} // end writeOneHTML


} // end jopackiH8
 
Ad

Advertisements

A

Andrew Thompson

A. Name said:
Someone please help me. This servlet is working when deployed in
tomcat in IE, but not in Netscape

1) You have failed to state the following
a) What does - IE working - mean (what is the
expected result of the servlet)?
b) Breaks in NN? How? What are the actual symptoms,
stacktrace or log etc.

2) Browsers are contankerous things, it is often
important to know, not just the make and version,
but also the OS (IE 5 on PC is a _completely_
different program to IE 5 on Mac)

3) Few people here have time to trawl through 31Kb
of your code. Trim it down to the bare minimum that
demonstrates the problem.
You often find that in doing so, the answer to the
problem becomes clear.

If you follow this advice you will have a far
greater chance of engaging some of the servlet
gurus here (I am _not_ one of them!)

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top