Results 1 to 7 of 7
  1. #1
    sathishvegeta is offline Member
    Join Date
    Feb 2013
    Posts
    20
    Rep Power
    0

    Default How to get a html result in a same page using servlet

    HI ...

    I need to get a result in same html page using servlet for Eg:
    i need to add two numbers and display the result in a same page using servlet. I have create htmlHow to get a html result in a same page using servlet-add.png and I need to get an answer in the below text box ...

    Seeking for help....

  2. #2
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    444
    Rep Power
    6

    Default Re: How to get a html result in a same page using servlet

    Hope the following steps would be helpful to you.

    a.) Instead of using HTML, use JSP page.

    b.) When user click addition button, doPost method of servlet has to be triggerd.

    c.) Capture your input values by using request.getParameter().

    d.) Do addition and then store result and input as request or session attribute.

    e.) Using request dispatcher forward request to input JSP.
    Mak
    (Living @ Virtual World)

  3. #3
    sathishvegeta is offline Member
    Join Date
    Feb 2013
    Posts
    20
    Rep Power
    0

    Default Re: How to get a html result in a same page using servlet

    Quote Originally Posted by makpandian View Post
    Hope the following steps would be helpful to you.

    a.) Instead of using HTML, use JSP page.

    b.) When user click addition button, doPost method of servlet has to be triggerd.

    c.) Capture your input values by using request.getParameter().

    d.) Do addition and then store result and input as request or session attribute.

    e.) Using request dispatcher forward request to input JSP.
    yep .. using request dispatcher forward request to html i need ..... not in jsp page anybody help me!!!!

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,920
    Rep Power
    19

    Default Re: How to get a html result in a same page using servlet

    Are you saying you cannot use a JSP for this?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    444
    Rep Power
    6

    Default Re: How to get a html result in a same page using servlet

    Quote Originally Posted by sathishvegeta View Post
    yep .. using request dispatcher forward request to html i need ..... not in jsp page anybody help me!!!!
    you can not forward html through request dispatcher. I wonder why you are worrying to use JSP instead of HTML? Both are rendering mark up text to browser.
    Mak
    (Living @ Virtual World)

  6. #6
    sathishvegeta is offline Member
    Join Date
    Feb 2013
    Posts
    20
    Rep Power
    0

    Default Re: How to get a html result in a same page using servlet

    Quote Originally Posted by Tolls View Post
    Are you saying you cannot use a JSP for this?
    yes it can be done in jsp ... but i need to get the sum two number in the same html page using servlet is it possiable???(in the above picture)

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,920
    Rep Power
    19

    Default Re: How to get a html result in a same page using servlet

    That's what makpandian has just explained to you.
    Submit to the servlet, then forward back to this JSP.
    This JSP will populate the 3 fields if there are values available in the request.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. redirect servlet page to html.
    By ayushi in forum Java Servlet
    Replies: 2
    Last Post: 07-23-2011, 07:57 PM
  2. call servlet result page in frameset
    By reubenmk in forum Java Servlet
    Replies: 0
    Last Post: 08-05-2010, 09:44 AM
  3. Servlet calling a new html page within it.
    By ServletEst in forum Java Servlet
    Replies: 6
    Last Post: 09-27-2009, 02:16 AM
  4. Adding result from jsp page to html
    By renuka_anil in forum Java Servlet
    Replies: 0
    Last Post: 03-23-2009, 07:33 AM
  5. Servlet should return a jsp page not html
    By hannehomuth in forum Advanced Java
    Replies: 1
    Last Post: 08-12-2008, 03:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •