Results 1 to 3 of 3
  1. #1
    shiva is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default How pass variable from jsp to servelet

    HI

    I used a function to the invoke the servlet, i need pass teh parameter ro my servlet pls let me know how to do that.
    I have pass fileName to DisplayLog servlet'.

    function display(fileName) {

    document.location.href = "DisplayLog";

    }

    Thanks
    shiva

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    765
    Rep Power
    6

    Default

    U can use sendredirect or forward method or sessions.

    Example for sendRedirect
    -----------------------
    response.sendRedirect("ur servlet path?fileName ='displaylog'")

  3. #3
    shiva is offline Member
    Join Date
    Mar 2009
    Posts
    14
    Rep Power
    0

    Default

    Thanks for the reply
    actually fileName is variable which im passing from the code. Im reading list of the file and display on jsp page. and if i click on the selected filename(i used button) it will call a the above function passing filename as paratermeter. Inturn i has to call the DisplayLog servlet to display the contents of the file. Please tell me how i redirect


    <div id="filelist">
    <%
    Object obj = request.getAttribute("filelist");
    if(obj != null) {
    String[] fileList = (String[]) obj;
    for (int i = 0; i < fileList.length; i++) {
    %>


    <input type="button" name="fileName" value=" <%=fileList[i]%>" onclick="display('<%=fileList[i]%>')"/>

    <br />

    <%
    }
    }
    %>

    </div>

Similar Threads

  1. calling the servelet code when the page is loaded
    By shivakumari in forum Java Servlet
    Replies: 1
    Last Post: 04-01-2009, 11:39 AM
  2. Pass by ref. A work around?
    By diRisig in forum New To Java
    Replies: 0
    Last Post: 02-05-2008, 07:25 PM
  3. How to pass an html variable as an applet value
    By fred in forum Java Applets
    Replies: 1
    Last Post: 08-06-2007, 03:28 AM
  4. Replies: 1
    Last Post: 08-03-2007, 10:52 AM

Posting Permissions

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