Obtaining Textfield Input from the User

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,817
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 4, 2008

Here's the original, full screen, full resolution video:

http://www.thebookonhibernate.com/j2ee/sunjavasamplecodetutorialsmockexams.js...


Obtaining Textfield Input from the User

This free, multimedia tutorial shows you how to use IBM's Rational Application Developer (IRAD) 6.0 to create an HTML file containing a form. Once the user submits the form, a Servlet is invoked, and the contents of the textfields of the form are read on the server side by the Servlet in question.

If you found something helpful here, please do your part and help support the site. Link to us, buy some books, support our sponsors, tell your developer friends about us, and remember: Happy Java!

package com.examscam.servlet;

import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class NumberGuesserServlet extends HttpServlet implements Servlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String magicNumber = System.currentTimeMillis() % 9 + 1 +"";
String guess = request.getParameter("guess");
if (guess.equals(magicNumber)){
response.getWriter().print("Correct! The magic number was: " + magicNumber);
}
else {
response.getWriter().print("Sorry, the magic number was: "+ magicNumber);
}
}

}

Please check out my SCJA Java Certification Mock Exam website: http://www.scja.com/associate/ And for Hibernate and JPA tutorials, check out: http://www.thebookonhibernate.com http://www.thebookonhibernate.com/j2ee/index.jsp?link=03httpsessionswf

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 1 dislikes

Link to this comment:

Share to:
see all

All Comments (1)

Sign In or Sign Up now to post a comment!
  • Thanks a lot for this perfect tut, may i ask what kind of IDE you have use?

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more