• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to insert into MongoDB

 
malik ge
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I don't know if this the right forum for asking this type of question.

In mysql I use to do:

Can anyone tell me how can I do that in mongodb?
I am getting the firstName and lastName from HTML form,
by "request.getParameter" and want to pass these values through Servlet to mongodb.

Thanks

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would first try a tutorial mongodb tutorial java
 
malik ge
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wendy Gibbons, I have a little knowledge about this:


but most of the tutorials I have found does the above.
What I wanna know if some new user with
name "James",
surname"Bond",
age 23
enters his information in the html form,
then how can I pass that to mongodb.

Means, how can I pass this information through "doc" object
doc.put("name" , ???);
doc.put("surname" , ???);
doc.put("age" , ???);
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which part is confusing you? how to get the details from the web form to the servlet or how to get the details from the servlet into the mongo database?
 
malik ge
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to get the details from the servlet into the mongo database?


I know by using Stirng name = request.getParameter("name"), I can get the name of the user.
but don't know how to insert that name, in the following code:
doc.put("name" , ???);
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
malik ge wrote:
how to get the details from the servlet into the mongo database?


I know by using Stirng name = request.getParameter("name"), I can get the name of the user.
but don't know how to insert that name, in the following code:
doc.put("name" , ???);


in your code have you tried
doc.put("name", name)?
 
malik ge
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic