• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Confusion about servlet

 
Mansi Kasar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I needed to practice servlet programs. I downloaded Eclipse Neon Java EE and Apache tomcat 7. Searched many sites and somehow I was able to configure tomcat in eclipse. While starting tomcat from eclipse server tab, it flashed error for "Ports 8005, 8080, 8009 are used by other services....". I tried changing the port numbers. After a lot try I  managed to start tomcat. Well, the tomcat shows running in eclipse, but when I type "localhost:8080 or any other port numbers that I used it doesn't show me the apache homepage".

I wrote a sample program as mentioned below. I tried running it as Java Server, but it shows error as "http status 404 - the requested resource is not available".

Need a proper guidance in this regard, I am confused!!

My sample program is:



And the console window of eclipse shows following message:

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:135)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:996)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
 
M Khalid
Ranch Hand
Posts: 45
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Insert this annotation before the class.

@WebServlet("/Test")


Example:



this is because the @WebServlet annotation is used to declare a servlet.
Here the servlet MyFirstServlet  is mapped to the URL pattern /Test (you can give any name for this URL).
 
Mansi Kasar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned I added @WebServlet("/Test") in my code but its still the same, same error is flashing
 
M Khalid
Ranch Hand
Posts: 45
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansi Kasar wrote:As mentioned I added @WebServlet("/Test") in my code but its still the same, same error is flashing


Restart the server and run the Servlet.
 
Mansi Kasar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay after restarting it is showing following message:

error_tomcat.png
[Thumbnail for error_tomcat.png]
 
M Khalid
Ranch Hand
Posts: 45
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansi Kasar wrote:Okay after restarting it is showing following message:



Its a configuration error with eclipse.
refer: Eclipse Community for this bug or configure and install Tomcat 8/9 Server run times.
 
M Ram
Greenhorn
Posts: 4
IntelliJ IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansi Kasar wrote:Hello. I needed to practice servlet programs. I downloaded Eclipse Neon Java EE and Apache tomcat 7. Searched many sites and somehow I was able to configure tomcat in eclipse. While starting tomcat from eclipse server tab, it flashed error for "Ports 8005, 8080, 8009 are used by other services....". I tried changing the port numbers. After a lot try I  managed to start tomcat. Well, the tomcat shows running in eclipse, but when I type "localhost:8080 or any other port numbers that I used it doesn't show me the apache homepage".

I wrote a sample program as mentioned below. I tried running it as Java Server, but it shows error as "http status 404 - the requested resource is not available".

Need a proper guidance in this regard, I am confused!!

My sample program is:



And the console window of eclipse shows following message:

Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens
at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:135)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:996)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)


user Tomcat 6 I had the same problem. I'm using Eclipse Mars and used Tomcat 8, it didn't work i got the same error messages. When i used Tocat 7 it's working fine since then. Just try with Tomcat 6 and tell me.
 
Mansi Kasar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it thanks..finally resolved
 
Lisa Austin
Ranch Hand
Posts: 108
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mansi Kasar wrote:Got it thanks..finally resolved


Was using TomCat 6 the resolution to this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic