Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Servlets

servlet

  • Please log in to reply
13 replies to this topic

#1 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 04 July 2008 - 01:39 AM

I just started to learn to use Servlets, using this tutorial:
Java Servlets - Part 1 [Java and J2EE]
The problem is when I reach page 4, running a Java Servlet, it doesn't work.
I followed the tutorial step by step, so i was wondering if the tutorial is corect?
I receive the folowing error message from TomCat.

HTTP Status 404 - /MyServlet

type Status report

message /MyServlet

description The requested resource (/MyServlet) is not available.
Apache Tomcat/6.0.16


TomCat is configured correct I think because the examples provided with the installation work.
Thanks!
  • 0

#2 Luke Bradley

Luke Bradley

    CC Lurker

  • Just Joined
  • Pip
  • 6 posts

Posted 05 July 2008 - 07:42 PM

TomCat is configured correct I think because the examples provided with the installation work.
Thanks!

Oh Golly, I haven't done servlets for awhile but I figure I'll try a response since nobody else is. As I recall, most of the problems like this would happen either because the tomcat manager didn't have a context for my app configured, or because there were problems in the meta files, like web.xml and so forth. However, I think one quick workaround might be to get an IDE that lets you do servlets, and look at what it sets up for you automatically. I used to use a version of Eclipse (free) with j2ee support:
EasyEclipse | Plugins | Eclipse J2EE tools
This lets you separate your work on servlets from your Tomcat configuration, which are both complex for beginners. After you have looked at the automatically generated files from eclipse for a simple project, you can try transfering them over to tomcat, that might help troubleshoot.
  • 0

#3 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 06 July 2008 - 12:47 AM

Thanks for the ideea.
I made servlets using Netbeans, but the thing it bother me was that tutorial, I did exactly what is says and it doesn't work.
  • 0

#4 Acti

Acti

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 07 July 2008 - 10:03 AM

Thanks for the ideea.
I made servlets using Netbeans, but the thing it bother me was that tutorial, I did exactly what is says and it doesn't work.


Well yes sometimes tutorial are made with genric aspects but the thing is that if you make a mistake with the settings It might end up with nothing but an error...

Usually I face this error when I have made a mistake in the web.xml file or this problem is also faced when you fail to connect the previous servlet page address properly...


In short if you express the problem in details maybe I could be of any help to you...

  • 0

#5 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 07 July 2008 - 10:51 AM

That's the thing, I did exactly like in that tutorial and I'm 80% sure is wrong. I read some more about Servlets and I thing the author there is wrong 'cause he doesn't say I should make any editing to the web.xml file, just to copy my class file and run it.
There are no other details, I did exactly what the tutorial said, no extra settings, and it doesn't work.
Even tried at work where the TomCat server is 100% configured right!
  • 0

#6 Acti

Acti

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 07 July 2008 - 11:33 AM

That's the thing, I did exactly like in that tutorial and I'm 80% sure is wrong. I read some more about Servlets and I thing the author there is wrong 'cause he doesn't say I should make any editing to the web.xml file, just to copy my class file and run it.
There are no other details, I did exactly what the tutorial said, no extra settings, and it doesn't work.
Even tried at work where the TomCat server is 100% configured right!


do u mean to say u dont edit the web.xml file at all???
  • 0

#7 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 07 July 2008 - 12:00 PM

yup :P
  • 0

#8 lowrider.v.7.0

lowrider.v.7.0

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 09 July 2008 - 08:12 AM

which platform are you on...windows or linux
  • 0

#9 tomitzel

tomitzel

    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 09 July 2008 - 09:42 AM

which platform are you on...windows or linux


Windows Vista Home Premium, but also I tried it at work on a Windows XP Professional. Same result.
Please someone, just follow the tutorial exactly, and tell me if it work for you at step 4
Thanks.
  • 0

#10 Acti

Acti

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 09 July 2008 - 11:10 AM

Windows Vista Home Premium, but also I tried it at work on a Windows XP Professional. Same result.
Please someone, just follow the tutorial exactly, and tell me if it work for you at step 4
Thanks.


Ok friend..I havent gone through the tutorial but if you say you havent gone through the web.xml file the let me show you an example of how your web.xml file is to be..


<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Copyright 2004 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.or...ses/LICENSE-2.0

-->

<web-app version="2.4">

<display-name>** your text**</display-name>
<description>
**Your text**
</description>


<!-- servlet mappings start -->

<servlet>
<servlet-name>Name of the servlet(keep it same as the name of class file to avoid confusions)</servlet-name>
<servlet-class>Name of the class file that will be invoked as servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Name of the servlet(keep it same as the name of class file to avoid confusions)**This will be same as the name u give above**</servlet-name>
<url-pattern>any pattern .. eg: (/s1/*) without brackets</url-pattern>
</servlet-mapping>

<!-- servlet mappings end -->

</web-app>
  • 0

#11 lowrider.v.7.0

lowrider.v.7.0

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 09 July 2008 - 11:13 AM

acti....are you sure that web.xml stuff is applicable for windows....or just for linux
  • 0

#12 Acti

Acti

    CC Newcomer

  • Just Joined
  • PipPip
  • 22 posts

Posted 09 July 2008 - 11:24 AM

yeh definately because you know that the taklu who looted me and pandu did'nt have linux so we had done servlets on windows and yes all the procedure is same in windows and linux regarding the WEB-INF folder and web.xml file and the CLASSES folder too...

Its only the address of the web.xml changes from /usr/share/..... to something as C:/Program files/tomcat......

thats all...
  • 0





Also tagged with one or more of these keywords: servlet

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download