Terry Li
Terry Li

Reputation: 17268

JSP wouldn't compile

<HTML>
<BODY>
Hello!  The time is now <%= new java.util.Date() %>
</BODY>
</HTML>

I tried to open this trivial jsp file with firefox, but the expression wouldn't evaluate. I have Java installed.

I'm new to JSP. Should I put the jsp in some specific directory? Or do I forget to include anything in the jsp file?

Upvotes: 0

Views: 86

Answers (4)

BalusC
BalusC

Reputation: 1109432

It sounds like that you aren't using a JSP/Servlet container at all but instead just opened the file straight from local disk file system by a file:// URL. This is indeed not going to work. You need to install a JSP/Servlet container. This is basically a HTTP web server which has the JSP compiler builtin and supports serving JSP/Servlets. A well known example is Apache Tomcat. Just download the zip under "Core" section (no, not the "Windows zip", really just "zip") and extract it on your disk. Then perform the following steps:

  1. Create a new subfolder in /webapps folder of Tomcat.
  2. Put the JSP file in that folder.
  3. Start Tomcat by the /bin/startup.bat (Windows) or /bin/startup.sh (Unix) script.
  4. Go in your browser to http://localhost:8080/foldername/yourfile.jsp where "foldername" is the name of the folder you created in step 1 and "yourfile.jsp" is the filename of the JSP you placed in step 2.

See also:

Upvotes: 2

Andre
Andre

Reputation: 691

Each jsp page must be compiled to a servlet by a JSP engine. Firefox is not a JSP engine. Have a look at JavaServer Pages Technology which might be helpful to you.

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 692121

A JSP is evaluated by a web container like Tomcat or Jetty, and the HTML that it generates is then sent to the browser. The browser can't run a JSP on its own.

Upvotes: 1

Nir Alfasi
Nir Alfasi

Reputation: 53545

Check your project library settings and that your java lib is in the class PATH.

Upvotes: 0

Related Questions