How to transfer data from. jsp to servlet?

Create a class which extends HttpServlet. Public class RegisterServlet extends HttpServlet {} Map this in web. Xml on an like /register.

RegisterServlet com.example. RegisterServlet registerServlet /register And just let form action point to this URL. I'd also recommend to use POST method.

Then create a doPost() method in your servlet which grabs the input as request parameters. The input field name is the request parameter name. Protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = request.

GetParameter("name"); String group = request. GetParameter("group"); String pass = request. GetParameter("pass"); // ... } Do if necessary some validations and finally persist it in the DB the usual JDBC/DAO way.

User user = new User(name, group, pass); userDAO. Save(user); See also: Servlets tag info page.

Note that the annotation is already hinted in the Servlets tag info page. In a follow-up question of the OP the OP is by the way already attempting to use the annotation (only in an incorrect way). – BalusC Feb 13 '11 at 4:56 Im sorry I assumed they had access to Servlets 3.0, I am sorry you specified a lot of what is already tied to Serlets tag info page, and did not include annotations.

I shall go away and stop attempting to extenuate your answer which I assume was a darn good one. Crawls into cave – Gorilla3D Feb 13 '11 at 5:56 @Gorilla: Huh? There is no need to crawl into cave :) – BalusC Feb 13 '11 at 12:50.

Well, there are plenty of database tutorials online for java (what you're looking for is called JDBC). But if you are using plain servlets, you will have a class that extends HttpServlet and inside it you will have two methods that look like public void doPost(HttpServletRequest req, HttpServletResponse resp){ } and public void doGet(HttpServletRequest req, HttpServletResponse resp){ } One of them is called to handle GET operations and another is used to handle POST operations. You will then use the HttpServletRequest object to get the parameters that were passed as part of the form like so: String name = req.

GetParameter("name"); Then, once you have the data from the form, it's relatively easy to add it to a database using a JDBC tutorial that is widely available on the web. I also suggest searching for a basic Java servlet tutorial to get you started. It's very easy, although there are a number of steps that need to be configured correctly.

oreilly.com/catalog/javacook/chapter/ch1... Search for : "Problem You want to process the data from an HTML form in a servlet.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions