Results 1 to 11 of 11
  1. #1
    buddy is offline Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default using servelts and Jsp

    Hi friends

    I am new to java.
    I want to write a function in servlet and I want to call it in Jsp.
    how can I do that??

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You submit the JSP to that servlet and in the servlet you call that function.
    What have you done so far?

  3. #3
    buddy is offline Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default

    r035198x

    can u give sample code to write method in servlet and call in jsp.I was just able to call the servlet with just basic output "hello" .
    I used the following code in jsp
    <%
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/abc");
    dispatcher.include(request,response);



    %>

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Don't write Java code in JSPs. What do you want the method to do? Like I said you don't actually call the method from the JSP, instead you submit the JSP to a servlet. The servlet then calls the method and could store the results(if any) as an attribute which that JSP or other JSPs can access.

  5. #5
    buddy is offline Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default

    I want to write just a small function in servlet.I have to send a parameter from jsp like "name " then it should return "Hello Name".

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    I have a special gift. When I post responses on some threads in forums, I can see them but other people cannot. I have always known there was something special about me.

  7. #7
    buddy is offline Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default

    why are u feeling so .I am new java learner that is the reason I cannot follow your replies easily

  8. #8
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default

    Quote Originally Posted by r035198x View Post
    I have a special gift. When I post responses on some threads in forums, I can see them but other people cannot. I have always known there was something special about me.
    I can see them. Naah na naaah na. :p;)
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  9. #9
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Find a JSP and servlets tutorials and read it first then.
    Sun's JavaEE tutorial is pretty comprehensive.

  10. #10
    buddy is offline Member
    Join Date
    Oct 2009
    Posts
    5
    Rep Power
    0

    Default

    ok sure ,but now I require that functionality, please tell me if it is possible or not, if it is then please give a sample code.
    Any function in servlet calling it in jsp.
    plzzzzzzzzzzz

  11. #11
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    OK, I have ripped this part from my secret message
    Quote Originally Posted by r035198x
    What do you want the method to do? Like I said you don't actually call the method from the JSP, instead you submit the JSP to a servlet. The servlet then calls the method and could store the results(if any) as an attribute which that JSP or other JSPs can access.

Posting Permissions

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