Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2005, 08:03 PM
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running JSP in Tomcat.

Hello,

I have installed Eclipse and Tomcat on my PC. I am able to run Java code without any problems using Eclipse. I am able to run servlets using tomcat. To run a servlet I had to create a web.xml file under WEB-INF folder and it worked.

Now, I am trying to run a "Hello world" JSP (in reality it is an HTML file as I have not included any Java code yet). I saved it as .JSP though. I created a folder "HelloWorld" and created JSPHelloWorld.jsp. When I enter "localhost/8080/HelloWorld/JSPHelloWorld.jsp" it does not recognize it. I did not create a web.xml file. Is that the problem? What kind of set up do I need to make? Tomcat is NOT that great when it comes to giving what the error is.

Please help!!

Thank you!!
 
Old March 31st, 2005, 12:22 AM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

   I think u forgot u write JSP tag in JSPHelloWorld.jsp.
  <%@ page contentType="text/html;charset=UTF-8" language="java" %>

  I think this will help u.

 
Old March 31st, 2005, 09:18 AM
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello artidatanova,

Thank you for responding. I tried with "<%@ page contentType="text/html;charset=UTF-8" language="java" %>". That did not seem to fix it. I suspect it is something specific to Eclipse/Tomcat setup. I ran into similar issues when I tried to run servlets.
 
Old March 31st, 2005, 05:29 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not creating a WEB XML file may well be your problem.
You also need to maintain the correct directory structure for files.

You can copy releveant folders including web xml from the jsp example setup into your webapp.

If you copy the web xml files and folders Tomcat will pick up the new webapp without manually entering the context for the site.

 
Old April 6th, 2005, 06:35 AM
Registered User
 
Join Date: Mar 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Hi

  OK.Then u should create a web.xml in WEB_INF folder,and make sure your directory structure are right:)

Here is code for web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<servlet>
  <servlet-name>AdministratorServlet</servlet-name>
  <servlet-class>AdministratorServlet</servlet-class>
 </servlet>
    <servlet-mapping>
        <servlet-name>AdministratorServlet</servlet-name>
        <url-pattern>/AdministratorServlet</url-pattern>
    </servlet-mapping>





</web-app>

Enjoy!

 
Old April 6th, 2005, 10:09 AM
Registered User
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, It worked!! Thank you! Appreciate your help very much.
 
Old December 17th, 2005, 08:10 PM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Javamaniac,
  I am trying to run a HelloWorld servlet on the Tomcat server that I installed on my machine. I followed the tutorial from http://javaboutique.internet.com/tut...e/index-2.html.

But I am not successful in getting the helloworld to work. Can you help me out.

Thanks,
Sampath






Similar Threads
Thread Thread Starter Forum Replies Last Post
running servlets on tomcat 6.0.18 tommytucson Apache Tomcat 1 December 3rd, 2008 07:16 AM
Running 2 instances of tomcat steevo590 Apache Tomcat 0 April 5th, 2006 12:53 PM
Servlet is running after tomcat is stopped. pandian Apache Tomcat 3 January 2nd, 2006 07:56 AM
Running both Oracle and Tomcat !!! amith_pj Apache Tomcat 7 November 5th, 2004 07:28 PM
Running TOMCAT on drive D: du-it JSP Basics 1 August 9th, 2004 07:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.