Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Simple Webapp

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple Webapp

    Hi, I'm trying to create a web application with a servlet but I couldn't get it to load to index.jsp. Can anyone tell me what I'm doing wrong? I'm pretty sure I already have the correct directory structure, with both index.jsp and web.xml directly under webapp/WEB-INF. I can access the servlet just fine by going to http://localhost:8080/MyApp/TestServlet, but my index.jsp doesn't load when I go to http://localhost:8080/MyApp. If it matters any, I'm using Eclipse Helios and Tomcat 6.0 as a plugin

    Here is my web.xml:

    <?xml version="1.0"?>
     
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    		http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    	version="2.5"> 
     
    	<servlet>
    		<servlet-name>TestServlet</servlet-name>
    		<servlet-class>com.myapp.servlet.TestServlet</servlet-class>
    	</servlet>
     
    	<servlet-mapping>
    		<servlet-name>TestServlet</servlet-name>
    		<url-pattern>/TestServlet</url-pattern>
    	</servlet-mapping>
     
    	<welcome-file-list>
    		<welcome-file>index.jsp</welcome-file>
    	</welcome-file-list>
    </web-app>

    Thanks in advance!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Simple Webapp

    What is the server response when you try to load the URL? 404? Did you try the full path (http://localhost:8080/MyApp/index.jsp) just to be sure?

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple Webapp

    Thanks for the quick reply. Yes, I'm getting a 404 response, and yes, I've just tried your URL and the same thing happens. I'm just wondering why accessing the servlet works but not the JSP.

  4. #4
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Simple Webapp

    This thread has been cross posted here:
    Trying to create a simple web app - Java Forums

    Although cross posting is allowed, for everyone's benefit, please read:
    Java Programming Forums Cross Posting Rules
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  5. #5
    Junior Member
    Join Date
    Feb 2011
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple Webapp

    The error was caused by spaces in my workspace location. I moved my workspace from C:\Documents and Settings\...\workspace to C:\workspace and the index.jsp location is now working fine. But now, accessing the servlet using the above URL is causing the 404 error. I'm so confused. :-(

Similar Threads

  1. help! simple ATM
    By galva in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 9th, 2010, 01:14 AM
  2. [SOLVED] Should be simple.
    By Time in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 22nd, 2010, 02:23 AM
  3. urgent simple help for a very simple program
    By albukhari87 in forum Java Applets
    Replies: 4
    Last Post: June 5th, 2010, 03:43 PM
  4. simple question...
    By chronoz13 in forum Java Theory & Questions
    Replies: 2
    Last Post: February 2nd, 2010, 07:29 AM
  5. not so simple, simple swing question box
    By wolfgar in forum AWT / Java Swing
    Replies: 2
    Last Post: November 20th, 2009, 03:47 AM