Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't Serve 1st JSP page

Status
Not open for further replies.

scripter73

Programmer
Apr 18, 2001
421
US
Hi,

I installed Tomcat 4.1 and the install directory is C:\Tomcat 4.1. Tomcat comes with examples in the following path: C:\Tomcat 4.1\webapps\examples\jsp, which has \dates\date.jsp.

I can run the following successfully:

I have also tested my Tomcat installation successfully by running:


Now I try to create another folder under C:\Tomcat 4.1\webapps\ called hJSP.

I created an index.jsp under hJSP:

<html>
<head>
<title>H JSP</title>
</head>

<body>
Hello, World!</p>
2 + 2 is ${2 +2} and 4 * 4 is ${4 *4}

</body>
</html>

I can't get index.jsp to run.

Here's my browser path:


Here's the error message I receive:


HTTP Status 404 - /hJSP/index.jsp

--------------------------------------------------------------------------------

type Status report

message /hJSP/index.jsp

description The requested resource (/hJSP/index.jsp) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/4.1.29




I've also included the directory paths in System vars.

What am I doing wrong? Why will the JSP serve in one webapps folder and not another?

Thanks for your help.

scripter73



Change Your Thinking, Change Your Life.
 
Ok. I restarted my machine and went back to

Now, I'm able to get the page to resolve, but here's what I get:

Hello, World!

2 + 2 is ${2+2} and 4 * 4 is ${4 *4}

Its not resolving the actual JSP logic. Any ideas?

Thanks in advance.




Change Your Thinking, Change Your Life.
 
JSP EL (expression language) is only available as part of the JSP 2 spec - which is currently only supported by Tomcat 5.
You'll need to upgrade your Tomcat version if you wish to use JSP EL.
 
Great. That clears up that question.

So if I have things written in EL and I want to convert to <%= %> notation, where's the best resource for finding out the syntax.

(I don't think I should upgrade to Tomcat 5 just yet until my company approves the update.)

Thanks,
scripter73


Change Your Thinking, Change Your Life.
 
Just use your intuition ! Its not hard to see that :

2 + 2 is ${2+2} and 4 * 4 is ${4 *4}

is :

2 + 2 is <%= 4 *4 %> and 4 * 4 is <%= 4 *4 %>
 
Thanks. Expressions, though, are very easy to figure out.

I was thinking more of an actual condition like the following:<%@ taglib uri=" prefix="c" %>

......

<c: forEach var="entry" items="${header}">
<tr>
<td>
${entry.key}
</td>
<td>
${entry.value}
</td>

</tr>

</c:forEach>

So are you saying I can just say things like:

<%= entry.key>

For some reason, I don't remember the syntax being that way in JSP.

Thanks in advance.

scripter73


Change Your Thinking, Change Your Life.
 
Ahh, yes well thats a little different !

Say the $header object was some kind of object like a Hashmap, it would be :

Code:
<%
 Iterator i = header.entrySet().iterator();
 while (i.hasNext()) {
   out.println("<td>" +i.next() +"</td>");
 }

%>

Obviously the syntax would change depending on what kind of object your "header" is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top