This week's book giveaway is in the Android forum.
We're giving away four copies of Learning Java by Building Android Games and have Jean-Marcel Belmont on-line!
See this thread for details.
Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

getting 404 and data not able to insert into database  RSS feed

 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear expert,

I have a form where the data will be inserted into the database when the user hit submit.
But, I am getting 404 error and it says my dao.tutorDAOFactory and daoMySql.tutorDAOImpl never used.












 
Master Rancher
Posts: 3671
40
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What URL is it trying to hit when you get the 404?

Also, you shouldn't be doing a generic "process" method for both GET and POST.
If you're adding data to the database it should just be a POST and either the GET does something else (retrieves data, for example), or returns a 404.
 
Saloon Keeper
Posts: 4845
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, the code is wide open to SQL insertion attacks. You should get up to speed on using PreparedStatement before using this code in a production setting.
 
tangara goh
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:What URL is it trying to hit when you get the 404?

Also, you shouldn't be doing a generic "process" method for both GET and POST.
If you're adding data to the database it should just be a POST and either the GET does something else (retrieves data, for example), or returns a 404.




The URL is :
http://localhost:8081/Hi5/addTutor

This is after I got rid of process and put everything under POST

I do not understand why the problem indicated that import daoMySQLtutorDAOImpl and import dao.tutorDAOFactory is never used.

Hope someone can point out anything wrong with the code.

Tks.

 
Rancher
Posts: 1893
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is addTutor?  Because the servlet mapping name appears to be tutorController?
 
Dave Tolls
Master Rancher
Posts: 3671
40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is indicating that those imports aren't used?
Not that that is going to be your issue.

As Swastik says, that URL does not match the mapping in the class.
 
tangara goh
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Swastik Dey wrote:What is addTutor?  Because the servlet mapping name appears to be tutorController?



Hi Swastik,

addTutor is an action that I want the servlet Controller to perform.  It is "mapped" to the jsp form.

Should I add a getPathServlet() in this case inside my servlet Controller ?

<div class="row">
<div class="col-md-8">
<h4>Tutor Registration</h4>
<form name="registerTutor" method="POST" action="addTutor" id="contactForm" novalidate>
 
tangara goh
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave and Swastik,

I think I found the answer, I forgot to put in the context file name.  And now there is no 404 error.

/contextfilename/addTutor
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!