Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Daniel Russell

Greenhorn
+ Follow
since Feb 04, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Russell

Rob Spoor wrote:

Daniel Russell wrote:Two Appweb? the folder and the name of the class?


Technically speaking the context path and the servlet path. (Note that I said the same except I used the term "war". That's how web applications are usually deployed.) But your servlet is mapped to /Appweb, not /Appweb/ or /Appweb/*. Try using http://localhost:8080/Appweb/Appweb (no trailing slash).

As for your error when you submit the form, that's because it's still trying to open http://localhost:8080/Appweb/. Unless you have an index.html, index.jsp or a welcome file in the root of your application, that URL simply does not exist.



Thank you! This is the solution! I have changed the url of the action="" to http://localhost:8080/Appweb/Appweb. Now it works.
1 week ago

Dave Tolls wrote:Right, based on the mappings in your web.xml, I would say your servlet resides at:
https://<servername>/Appweb/Appweb

The first Appweb is the application name (based on the folder name in webapps).
The second is what you have mapped the servlet to.

As for the message, it means the IDE cannot find either the source code or the Javadoc for those classes, and so cannot do it's usual trick of popping up the Javadoc description of the class.




Two Appweb? the folder and the name of the class?

When I open my hello.html, then I complete the form and I press 'submit', in the 404 error page the url written up the page is "http://localhost:8080/Appweb/". You mean the right url would be something like "http://localhost:8080/Appweb/Appweb/"? But even if I change to this, the error is the same.

the strange thing is that if I write http://localhost:8080/Appweb/hello.html, then it goes to the page with he form. When I press the button "submit" then it goes to the url http://localhost:8080/Appweb/  and then it show up the error message: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

1 week ago

Daniel Russell wrote:

Dave Tolls wrote:No, not your project.
What is deployed to tomcat?
What does the webapp folder under tomcat look like?

What you show there is your project, this is not the same thing that is deployed to the server.

If you don't know where to look, then how do you deploy your webapp?



You mean the folder in tomcat?

If so, it's this one:

wtpwebapps-

      Appweb-

        hello.html
       
        META-INF-
         
           MANIFEST.MF

        WEB-INF-
         
           web.xml

          classes-
         
                 helloservlets-
   
                     Appweb.class


          lib (empty)




I found another problem that likely is related to the 404 problem.

when I hover with the mouse those package:



I see this message: Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

What's the meaning of this message?

My problem is related to get and post method, because the 404 appears when I click to submit button.
So there must be something to fix in HttpServletRequest.
1 week ago

Dave Tolls wrote:No, not your project.
What is deployed to tomcat?
What does the webapp folder under tomcat look like?

What you show there is your project, this is not the same thing that is deployed to the server.

If you don't know where to look, then how do you deploy your webapp?



You mean the folder in tomcat?

If so, it's this one:

wtpwebapps-

      Appweb-

        hello.html
       
        META-INF-
         
           MANIFEST.MF

        WEB-INF-
         
           web.xml

          classes-
         
                 helloservlets-
   
                     Appweb.class


          lib (empty)


1 week ago

Dave Tolls wrote:

Daniel Russell wrote:
If I go to WEB-INF/lib, in the lib folder there's nothing. If the servlet class is "helloservelets" in my case, then it has this directory: eclipse-workspace/Appweb/src/helloservlets. That is the directory in which I find the file Appweb.java. In web-inf there is only my web.xml. Does it means that I have to change the directory of helloservlets?



That sounds like it hasn't been deployed correctly.

Can you post the directory structure under your tomcat/webapps (not as a screenshot).

It should be something like:
webapp -
   Appweb -
       <html files>
       WEB-INF -
           classes -
               <your class directory structure helloservlet/Appweb.class>
           lib -  (probably empty)



My project has this structure:

Appweb- (folder of the project in workspace)

     build -
       classes-
          helloservlets-
                Appweb.class

     src-
         helloservlets-
           Appweb.java

     WebContent-
        hello.html

          META-INF-
             MANIFEST.MF
     
          WEB-INF-
             web.xml
             lib (empty)



So the class is in the build folder, not in the WEB-INF.
1 week ago

Rob Spoor wrote:

Daniel Russell wrote:The url in the browser is this one: http://localhost:8081/Appweb/.


That's missing the context path, which is the name of the WAR file (minus .war). Unless you deploy a WAR as the root application, you need to use its content path.



I'm not using a war file in my project, instead I'm using a web.xml and a hello.html. At the moment  I open the html file in the web browser, I complete the form and then, when I press the submit button, it appears the message: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists", in the error 404 page.

The Hello.html is this one:

1 week ago

Bear Bibeault wrote:Had you worked through the troubleshooting list in the ServletsFaq for resource 404 errors?

[Edit: link ]



I have to understand this one:

"Make sure that the servlet class is properly placed under the WEB-INF/classes hierarchy, or properly packaged in a jar file in WEB-INF/lib."

If I go to WEB-INF/lib, in the lib folder there's nothing. If the servlet class is "helloservelets" in my case, then it has this directory: eclipse-workspace/Appweb/src/helloservlets. That is the directory in which I find the file Appweb.java. In web-inf there is only my web.xml. Does it means that I have to change the directory of helloservlets?
1 week ago

Daniel Russell wrote:

Bear Bibeault wrote:

Daniel Russell wrote:Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.


Then this is the first thing to fix rather than side-step around.

The resource not available error likely means a configuration issue. There's a checklist in the ServletsFaq to help find out what the issue is.

If something else is running on 8080, likely a runaway instance of tomcat, you need to know about it.



When I try to use port 8080, when I start tomcat it apperas this message:

"Port 8080 required by Tomcat v8.5 Server at localhost (2) is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s)."

In the past I have chosen the second option, that was to pass to port 8081.



I have found a process running and I have killed him from terminal. Now I'am able to use port 8080, but when I try to submit my form the error is the same as before, it's the 404: "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.".
1 week ago

Bear Bibeault wrote:

Daniel Russell wrote:Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.


Then this is the first thing to fix rather than side-step around.

The resource not available error likely means a configuration issue. There's a checklist in the ServletsFaq to help find out what the issue is.

If something else is running on 8080, likely a runaway instance of tomcat, you need to know about it.



When I try to use port 8080, when I start tomcat it apperas this message:

"Port 8080 required by Tomcat v8.5 Server at localhost (2) is already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s)."

In the past I have chosen the second option, that was to pass to port 8081.
1 week ago

Bear Bibeault wrote:You are running tomcat on port 8081?  

What we also need to see is your web.xml. Posted as text and using code tags (see UseCodeTags).



Yes, I'm using port 8081, because 8080 gives me problem. If I use 8080 the Bowser show me the message: "The requested resource is not available." and I have also problem with tomcat,
because tomcat say that 8080 is already in use, or something like that.

My web.xml is:



I have already tried to change /Appweb to /Appweb/*, but nothing change.
1 week ago

Tim Moores wrote:Welcome to the Ranch.

In the future, please do not post screenshots, which make it impossible to quote or copy - post the actual text, preferably in CODE tags.

Which URL is displayed in the browser?




The url in the browser is this one: http://localhost:8081/Appweb/.

1 week ago
I get an error message: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists. This happens when I click on the submit button of the form. My poject is composed of three files: Appweb.java, hello.html and web.xml. I have already tried to reinstall tomcat or check tomcat manager, or check the code for some mistake, but I have found nothing.
1 week ago