• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusion about servlet

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 100
2
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 100
2
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 100
2
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
IntelliJ IDE Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it thanks..finally resolved
 
Ranch Hand
Posts: 333
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mansi Kasar wrote:Got it thanks..finally resolved



Was using TomCat 6 the resolution to this?
 
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic