must convert PHP script to JSP



One of the remote servers hosting me has dropped PHP support in favor
of J2EE-only, leaving me to have to convert a series of PHP scripts to
JSP, and so far I'm failing miserably.

URL: http://www.myjavaserver.com/~ppowell/chat.jsp

Simple purpose: Just for now: a chatroom login page, looks for user
entry and redirects if found, else, just shows some pretty HTML and
that's it.

Here is the PHP script:

[PHP]
<?

/*--------------------------------------------------------------------------
File: CHAT.PHP
Created By: Phil Powell
Creation Date: 3/1/2004
Modified Date: 3/1/2004
Purpose: Display for chatroom signup and room popup window
Dependencies: NONE
Cookies: NONE
Sessions: NONE
Structure: Standalone main file

---------------------------------------------------------------------------*/

// INCLUDE GLOBAL VARS

require_once('/members/EcbGOSyXT2sNSZYWMtGsBX70dog4ZKpP/includes/chat_global_vars.php');

// INCLUDE CLASSES
require_once("$ABSOLUTE_MYCGISERVER_PATH/$PATH/chat_classes.php");

// HEADER/MENUBAR DISPLAY CAPTURE/RETRIEVAL
$htmlRetriever = new HTMLRetriever("$SELF/includes/chat_header.jsp");
$html .= $htmlRetriever->getHTML(); // HEADER
$htmlRetriever = new
HTMLRetriever("$SELF/includes/chat_menubar.jsp");
$html .= $htmlRetriever->getHTML(); // MENUBAR
$htmlRetriever = new
HTMLRetriever("$SELF/includes/chat_center_js_display.html");
$html .= $htmlRetriever->getHTML(); // CENTER JAVASCRIPT DISPLAY
$htmlRetriever = new
HTMLRetriever("$SELF/includes/chat_disclaimer.jsp");
$html .= $htmlRetriever->getHTML(); // DISCLAIMER

if ($_COOKIE['val_chat']) {
// OPEN UP A NEW WINDOW TO SHOW THE CHATROOM
ob_start();

require_once("$ABSOLUTE_MYCGISERVER_PATH/$PATH/chat_open_room.php");
$html .= ob_get_contents();
ob_end_clean();
} elseif ($_POST['hasEnteredNick']) {

require_once("$ABSOLUTE_MYCGISERVER_PATH/$PATH/chat_validation.php");
} else {
// DISPLAY NICKNAME FORM
ob_start();

require_once("$ABSOLUTE_MYCGISERVER_PATH/$PATH/chat_nickname_form.php");
$html .= ob_get_contents();
ob_end_clean();
}

$htmlRetriever = new
HTMLRetriever("$SELF/includes/chat_footer.html");
$html .= $htmlRetriever->getHTML(); // FOOTER

echo $html;
$htmlRetriever = null;

?>
[/PHP]

This is the best I could translate to JSP:

[JSP]
<%@ page import="ppowell.*" %>

<%!

String html = "", cookie = "";

HTMLRetriever htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_header.jsp"); %>
html += htmlRetriever.getHTML(); // HEADER
htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_menubar.jsp");
html += htmlRetriever.getHTML(); // MENUBAR
htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_center_js_display.jsp");
html += htmlRetriever.getHTML(); // CENTER JAVASCRIPT DISPLAY
htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_disclaimer.jsp");
html += htmlRetriever.getHTML(); // DISCLAIMER

CookieRetriever cookieRetriever = new CookieRetriever("http://"; +
ChatGlobals.SERVER_NAME, ChatGlobals.CHAT_COOKIE_NAME);
cookie = cookieRetriever.getCookieVal();

if (cookie.length() > 0) {
// OPEN UP A NEW WINDOW TO SHOW THE CHATROOM
htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_open_room.php");
} else if (request.getParameter("hasEnteredNick") != null) {
// GO TO VALIDATION
} else {
// DISPLAY NICKNAME FORM
htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_nickname_form.php");
}
html += htmlRetriever.getHTML();

htmlRetriever = new HTMLRetriever(ChatGlobals.SELF +
"/includes/chat_footer.html");
html += htmlRetriever.getHTML(); // FOOTER

%>

<html>
<head>
<title><%= ChatGlobals.BRAND_HTML %> Chat</title>
</head>
<body>
<%= html %>
</body>
</html>
[/JSP]

The results are nasty. It produces raw JSP code to the browser instead
of HTML every time. I am unable to figure out what I could be doing
wrong since this is hosted remotely.

Anyone have any idea what could be going wrong with this?

thanx
Phil

.