Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NetBean button not working

 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




And I execute the HTML, everything is work fine but whenever I press the "Submit" button, then a error popped out.

 
Paul Clapham
Sheriff
Posts: 21572
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


What URL does that post to? Possibly it doesn't contain the context path for the web app, as it should? Or is your web app configured as Tomcat's default web app?
 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:

What URL does that post to? Possibly it doesn't contain the context path for the web app, as it should? Or is your web app configured as Tomcat's default web app?


Which mean the path is wrong? So it doesn't find the servlet?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL should be server-relative, meaning that it starts with the context path. See the JspFaq for more information on obtaining this value.
 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The URL should be server-relative, meaning that it starts with the context path. See the JspFaq for more information on obtaining this value.


The problem still can't be solve.
I have change the code path to full path

Whenever I click the button, it doesn't execute anything.
If that anything I mistake on the .java code or html? Need assistance. Much appreciate.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No one said anything about the full file path. That's not the context path. Did you look at the JspFaq on resource referencing as instructed? http://www.coderanch.com/t/659912/Wiki/Resource-Url-Problems
 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah. I read already as well as tried a lot of stuffs.
But it still can't work properly.

I am creating EJB, and I am create, develop the web-apps inside the (-WAR) folder.
So now I have index.html and indexServlet.java, the code is shown above.

I need more advise to get it success. Cheer.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it would be useful for you to show us your new form action url?
 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Maybe it would be useful for you to show us your new form action url?



I change the the index.html form action url into this full path,
by the way, I am using glassfish 4.1 server instead of tomcat.

And question, Do i need to clean & build and deploy the project?
 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
https://www.daniweb.com/programming/web-development/threads/503809/netbean-ejb-web-apps#post2201783

I also had ask some people on this forum, please kindly see this forum and see the images.
I had posted the images of my root directory as well as the index.html form action URL.
 
Dave Tolls
Ranch Hand
Posts: 2102
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, you are deploying a .java source file. That should be a compiled class file.
Second you have placed it directly under WEB-INF. It should be in the classes folder, in its correct package.
Third you are referencing it in the form directly. Nothing under WEB-INF can be accessed by the client. It essentially doesn't exist as far as the client is concerned. The target servlet should be defined either by annotations or in the web.xml. Looking at your class it is defined in the annotation, so that's OK.
 
gah hon
Greenhorn
Posts: 26
C++ Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:First, you are deploying a .java source file. That should be a compiled class file.
Second you have placed it directly under WEB-INF. It should be in the classes folder, in its correct package.
Third you are referencing it in the form directly. Nothing under WEB-INF can be accessed by the client. It essentially doesn't exist as far as the client is concerned. The target servlet should be defined either by annotations or in the web.xml. Looking at your class it is defined in the annotation, so that's OK.


So what is the actual problem to caused this error?
 
Dave Tolls
Ranch Hand
Posts: 2102
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you'd need to compile your code to get class files, and then deploy it so those class files end up in the correct directory under WEB-INF.

That covers 1 and 2 of my points.

Part 3 is covered by referring to the link Bear gave earlier about urls.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic