开发者

JSP and Tomcat - can't see time, only see code

开发者 https://www.devze.com 2023-02-08 13:02 出处:网络
Hey, I\'m new to Tomcat 开发者_如何学Goand JSP. I have the following code in a .jsp file in the webapps folder of tomcat, but when I open it in my browser (Firefox) it doesn\'t display the time, but s

Hey, I'm new to Tomcat 开发者_如何学Goand JSP. I have the following code in a .jsp file in the webapps folder of tomcat, but when I open it in my browser (Firefox) it doesn't display the time, but shows that part of the code.

Why is this?

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


  • Make sure your file is located in a folder inside webapps. You should not place files directly in the folder. Put it in webapps/example.

  • Make sure your page has the .jsp extension - then it should be handled by the JSP servlet and the expression - evaluated.

  • Make sure you are accessing it via http://localhost:8080/example/page.jsp, where example is the name of the folder within webapps. If you are accessing it as a local file, then tomcat does not get the chance to evaluate the expressions, of course.


What's the URL you are using to Open the JSP file?

If it's something like:

file:///Users/tom/tom.jsp

Then it won't work since you are not letting any application server to HANDLE your request.

You need point the URL to TOMCAT's WebRoot folder. It will be something like:

http://localhost:8080/webappname/tom.jsp

Also, please provide the way you are deploying your web application in order to give you proper help.

0

精彩评论

暂无评论...
验证码 换一张
取 消