Include servlet-out in another servlet

Hi,
is there a way to include the output of one servlet in another one? The only possibility I have found is to call the other servlet via http ( i am using org.apache.httpclient) but the problem with this technique is, that I couldn�t find a way to get the same sessions in both servlets.
Is there anyone who know how to do that?
Thanks,
faralla

I think a method which also uses the RequestDispatcher.include could work. But I haven't tested it, so I am not sure.
Give it a HttpServletResponseWrapper in which you overwrite the getWriter() and getOutputStream()
Extend ServletOutputStream
make an instance variable of java.io.ByteArrayOutputStream (later used to get the string with toString())
overwrite the abstract write(int b) method to call the same method
on the ByteArrayOutputStream.
make a public method to get the ByteArrayOutputStream
Extend HttpServletResponseWrapper
make an instance of your ServletOutputStream
make an instance variable of java.io.PrintWriter where you overgive the constructor the ByteArrayOutput of your ServletOutputStream
overwrite the getOutputStream() to return you ServletOutputStream
overwrite the getWriter() method to return java.io.PrintWriter
make a public method to get your ServletOutputStream
now get the RequestDispatcher and call insert(noramlReq,instanceof your
HttpServletResponseWrapper)
afterwards get the your ServletOutputStream and from it get the ByteArrayOutputStream
call on the ByteArrayOutputStream toString()

Similar Messages

  • How can one servlet (ActionServlet) effect another servlet (AxisServlet)...

    Recent issue is driving me batty. Suddenly started receiving exceptions in app server logs (tomcat a la jboss)...
    Servlet.service() for servlet AxisServlet threw exception
    java.lang.IllegalStateException
    org.apache.catalina.connector.ResponseFacade.setBufferSize(ResponseFacade.java:220)
    org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:610)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    After many many hours of research, appears that I get this exception if a specific struts action (one of several) executes at the same time as a SOAP call to the AxisServlet. It ends up causing the return of an empty dataset to the calling SOAP client (and giving me a bad headache to boot).
    Weird.
    The actions that appear to cause this aren't special in any way (not any different than other actions in my application), but I am obviously missing something. I have a suspicion that the struts actions that cause this are all chained events (one action calls another which leads to a JSP....but can't completely confirm).
    Any thoughts? How can the activities of one servlet effect another such as this? Yes...they are in the same war/ear......and they probably share some common classes.....
    For the record...Jboss 4./tomcat 5.5 Struts 1.3X and Axis 1.2 (although have tried 1.4...same results). Java 1.5 on FreeBSD 6.0.
    Any help would be appreciated.

    If the other servlet is in a web-app in the same container, you can use RequestDispatcher, if not you would have to use a URLConnection.

  • Servlet Calls another Servlet, Returns an Object

    Is it possible to call another servlet (which is loaded through
              Load-on-startup) from another servlet. The return should be an Object.
              I know I am kind of asking for a procedural way of programming.
              Example : Servlet "IamReady" is loaded and gets a request with binary
              data. It replies with a Binary Object.
              Servlet "serviceCall" calls IamReady to get the resoponse.
              I know that there are forward (using requestDispatcher) and "include"
              directives to have another servlet service calling servlet.
              Also, if I define a method in the (generic servlet) does each call to
              methos is executed in different thread (like doPost and doGet).
              Thanks.
              Chris
              

    "Michael Reiche" <[email protected]> wrote in message news:<[email protected]>...
              Thank you Michael,
              > It is possible to call a servlet from a servlet.
              >
              > You can 'return' an object by putting it in the httpRequest.
              You mean httpResponse.
              >
              > The call is NOT executed in a separate thread.
              >
              > From this post (and the other post about a connection pool) - I wonder if
              > you really need to be using servlets. I couldn't think of a good reason why
              > the connection pool needs to be a servlet.
              Are you suggesting I should just have a class. Reason I have it as
              servlet, b'caz I do a load-on-startup and do initialiazation etc. in
              the init method. May be if you suggest how I can do it otherwise, I
              would like to implement it that way.
              Thanks again.
              >
              > Mike
              >
              > "MOL" <[email protected]> wrote in message
              > news:[email protected]...
              > > Is it possible to call another servlet (which is loaded through
              > > Load-on-startup) from another servlet. The return should be an Object.
              > > I know I am kind of asking for a procedural way of programming.
              > >
              > > Example : Servlet "IamReady" is loaded and gets a request with binary
              > > data. It replies with a Binary Object.
              > >
              > > Servlet "serviceCall" calls IamReady to get the resoponse.
              > >
              > > I know that there are forward (using requestDispatcher) and "include"
              > > directives to have another servlet service calling servlet.
              > >
              > > Also, if I define a method in the (generic servlet) does each call to
              > > methos is executed in different thread (like doPost and doGet).
              > >
              > > Thanks.
              > >
              > > Chris
              

  • I want to send a response from the servlet and then call another servlet.

    Hi,
    I want to send a response from the servlet and then call another servlet. can this happen. Here is my scenario.
    1. Capture all the information from a form including an Email address and submit it to a servlet.
    2. Now send a message to the browser that the request will be processed and mailed.
    3. Now execute the request and give a mail to the mentioned Email.
    Can this be done in any way even by calling another servlet from within a servlet or any other way.
    Can any one Please help me out.
    Thanks,
    Ramesh

    Maybe that will help you (This is registration sample):
    1.You have Registration.html;
    2.You have Registration servlet;
    3.You have CheckUser servlet;
    4.And last you have Dispatcher between all.
    See the code:
    Registration.html
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
      <HEAD>
        <TITLE>Hello registration</TITLE>
      </HEAD>
      <BODY>
      <H1>Entry</H1>
    <FORM ACTION="helloservlet" METHOD="POST">
    <LEFT>
    User: <INPUT TYPE="TEXT" NAME="login" SIZE=10><BR>
    Password: <INPUT TYPE="PASSWORD" NAME="password" SIZE=10><BR>
    <P>
    <TABLE CELLSPACING=1>
    <TR>
    <TH><SMALL>
    <INPUT TYPE="SUBMIT" NAME="logon" VALUE="Entry">
    </SMALL>
    <TH><SMALL>
    <INPUT TYPE="SUBMIT" NAME="registration" VALUE="Registration">
    </SMALL>
    </TABLE>
    </LEFT>
    </FORM>
    <BR>
      </BODY>
    </HTML>
    Dispatcher.java
    package mybeans;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import javax.servlet.RequestDispatcher;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Dispatcher extends HttpServlet {
        protected void forward(String address, HttpServletRequest request,
                               HttpServletResponse response)
                               throws ServletException, IOException {
                                   RequestDispatcher dispatcher = getServletContext().
                                   getRequestDispatcher(address);
                                   dispatcher.forward(request, response);
    Registration.java
    package mybeans;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Registration extends Dispatcher {
        public String getServletInfo() {
            return "Registration servlet";
        public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            ServletContext ctx = getServletContext();
            if(request.getParameter("logon") != null) {          
                this.forward("/CheckUser", request, response);
            else if (request.getParameter("registration") != null)  {         
                this.forward("/registration.html", request, response);
    CheckUser.java
    package mybeans;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class CheckUser extends Dispatcher {
        Connection conn;
        Statement stat;
        ResultSet rs;
          String cur_UserName;
        public static String cur_UserSurname;;
        String cur_UserOtchestvo;
        public String getServletInfo() {
            return "Registration servlet";
        public void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            try{
                ServletContext ctx = getServletContext();
                Class.forName("oracle.jdbc.driver.OracleDriver");
                conn = DriverManager.getConnection("jdbc:oracle:oci:@eugenz","SYSTEM", "manager");
                stat = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
               String queryDB = "SELECT ID, Login, Password FROM TLogon WHERE Login = ? AND Password = ?";
                PreparedStatement ps = conn.prepareStatement(queryDB); 
               User user = new User();
            user.setLogin(request.getParameter("login"));
            String cur_Login = user.getLogin();
            ps.setString(1, cur_Login);
            user.setPassword(request.getParameter("password"));
            String cur_Password = user.getPassword();
            ps.setString(2, cur_Password);
         Password = admin");
            rs = ps.executeQuery();
                 String sn = "Zatoka";
            String n = "Eugen";
            String queryPeople = "SELECT ID, Surname FROM People WHERE ID = ?";
           PreparedStatement psPeople = conn.prepareStatement(queryPeople);
                      if(rs.next()) {
                int logonID = rs.getInt("ID");
                psPeople.setInt(1, logonID);
                rs = psPeople.executeQuery();
                rs.next();
                       user.setSurname(rs.getString("Surname"));
              FROM TLogon, People WHERE TLogon.ID = People.ID";
                       ctx.setAttribute("user", user);
                this.forward("/successLogin.jsp", request, response);
            this.forward("/registration.html", request, response);
            catch(Exception exception) {
    }CheckUser.java maybe incorrect, but it's not serious, because see the principe (conception).
    Main is Dispatcher.java. This class is dispatcher between all servlets.

  • What is the best way to call a servlet from another servlet?

    I have a project with 9 servlets (class project). The way I have been moving from servlet to servlet is like this
    doPost(...)
    {      response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head><title>Functions</title>");
    out.println(f"<form name=frm6 method=post action=/servlet2");
    out.println("<input type=submit name='btn' value='servlet2'>");
    out.println("</form>");
    So I have these 9 servlets - I call any 8 of them from the first servlet so I have 8 buttons on 8 forms <form=frm1, frm2, ...frm8 method = post...> But when I bring up the first servlet only 6 buttons show up. I was thinking about using hyperlinks instead, but I would like to do this with buttons. I wanted to do this with javascript and the location object, but I was advised to use jsp. I just want to move from one servlet to the next. Any suggestions appreciated for the best/preferred method for moving from one servlet to the next.
    Thanks

    I think you may need some clarification of terminology etc..
    First off, JSP isn't an alternative to javascript, it's an alternative to coding a servlet. A JSP is a mixture of java code and HTML and is translated into a servlet by the system. JSPs are primarilly for generating HTML pages with variable content. JSPs very frequently generate HTML which includes Javascript.
    You probably shouldn't think of what you're doing as one servlet invoking another, that does happen; a servlet can transfer an transaction to another servlet or JSP. In fact it's standard practice that a servlet does the logical stuff (like interpretting form data) then transfers to a JSP to generate the response page. However in this case it's the browser that can invoke one of the 8 servlets, the first servlet merely creates the page from which they are invoked.
    It's not obvious why only some of your buttons are showing up. In a case like this use the "view source" option on your browser to find out what HTML the servlet is actually delivering. What's wrong should be evident from that.
    You can put a hyperlink arround a button, or an image. Mostly people turn up their noses at the buttons supplied by HTML and use their own images for buttons. You
    can do somthing like this:
    <img src="/images/button3.png" border="0">
    (Of course this arrives as a GET transaction not a POST).
    Or you can do a bit of javascript like:
    <img src="/images/button3.png" style="Cursor: pointer;"
    onclick="document.locations.href='/servlet3';">

  • Calling another servlet from a servlet

    I'm working on a servlet and would like to know how to
    call another servlet, by clicking on a form button
    or a hyperlink that was generated from the first servlet,
    is it only possible if the second servlet is called
    in an shtml page? Can you please give me an example
    of how to do this not using shtml pages?
    (I'm working with JDeveloper 2.0)
    When will the book be out for JDeveloper 2.0?
    We're also having problems deploying the servlet
    to the Java Web Server (1.1.3)
    It seems to have a problem connecting to the database.
    We get the first page of the servlet but the
    second page is generated from the doPost()
    and connects to the database using oracle JDBC thin
    gives a http 500 internal server error ,
    and we followed the instructions from JDeveloper
    can the problem be caused from the connection string that
    I used in the servlet:
    Class.forName("oracle.jdbc.driver.OracleDriver");
    DriverManager.registerDriver(
    new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(
    "jdbc:oracle:thin:@(description=(address=
    (host=10.10.10.53)(protocol=tcp)(port=1521))
    (connect_data=(sid=OR8A)))",
    "im_dev","im_dev");
    or the configuration of the web server?
    (web server: Solaris 2.7 running on Intel)
    null

    Hi
    The sample acme video demo in JDeveloper does something similar.
    It has main Servlet "WebAppServlet.java" which overides the
    doPost and doGet methods and this methods calls someother java
    classes do perform some specific business logic which return a
    html page in a String format to "WebAppServlet.java".
    Open the samples directory in JDEveloper 2.0 with WebApp_81.jws
    to look at the source code.
    Steps to run the sample are included in the help system.
    regards
    argyro (guest) wrote:
    : I'm working on a servlet and would like to know how to
    : call another servlet, by clicking on a form button
    : or a hyperlink that was generated from the first servlet,
    : is it only possible if the second servlet is called
    : in an shtml page? Can you please give me an example
    : of how to do this not using shtml pages?
    : (I'm working with JDeveloper 2.0)
    : When will the book be out for JDeveloper 2.0?
    : We're also having problems deploying the servlet
    : to the Java Web Server (1.1.3)
    : It seems to have a problem connecting to the database.
    : We get the first page of the servlet but the
    : second page is generated from the doPost()
    : and connects to the database using oracle JDBC thin
    : gives a http 500 internal server error ,
    : and we followed the instructions from JDeveloper
    : can the problem be caused from the connection string that
    : I used in the servlet:
    : Class.forName("oracle.jdbc.driver.OracleDriver");
    : DriverManager.registerDriver(
    : new oracle.jdbc.driver.OracleDriver());
    : con = DriverManager.getConnection(
    : "jdbc:oracle:thin:@(description=(address=
    : (host=10.10.10.53)(protocol=tcp)(port=1521))
    : (connect_data=(sid=OR8A)))",
    : "im_dev","im_dev");
    : or the configuration of the web server?
    : (web server: Solaris 2.7 running on Intel)
    null

  • How to call a specific method in a servlet from another servlet

    Hi peeps, this post is kinda linked to my other thread but more direct !!
    I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?
    Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.
    I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ??
    Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ???
    Cheers
    Kevin

    Thanks for the reply.
    So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?
    getrequestdispatcher.include(newDAO.login())
    where newDAO is an instance of the class DAO, would that be correct ?? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!
    Kevin

  • How can I include a file in a servlet?

    I need to include a header file in htm format and a footer as well. My question here is, is it possible to include these files when a servlet is executed? like in the cases of the jsp web apps, with the <%@include file = "header.htm"%> tag... please let me know and thanks in advance.
    Regards

    Use RequestDispatcher.include:
    RequestDispatcher rd =
    = this.getServletContext().getRequestDispatcher(url);
    try { rd.include(request, response); }
    catch (Exception e) { "Error : Dispatch includeError
    : " + e); }Where url is the relative url of the HTML file.Hi, thanks for your answer, I still having a problem there, I used the RequestDispatcher.Include but it didn't show the file this is the code I'm trying to use:
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    OutputStream out = response.getOutputStream();
    RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/form.htm");
    try {
    rd.include(request, response);
    catch (Exception e)
    System.out.println("Error : Dispatch includeError : " + e);
    try {
    IntervalCategoryDataset dataset = createGanttDataset();
    System.out.println("Total Categories: " + dataset.getCategoryCount());
    System.out.println("Total series: " + dataset.getSeriesCount());
         JFreeChart chart = ChartFactory.createGanttChart("Activities for F3319G1", "Activity", "Date", dataset, true);
    response.setContentType("image/png");
         ChartUtilities.writeChartAsPNG(out, chart, 800, 600);
    catch (Exception e) {
    e.printStackTrace();
    System.err.println(e.toString());
    finally {
    out.close();
    This servlet gets an image.. so the ContentType is set to "image/png" I don't know if this is causing the problem in such case what would I need to include an html or htm file in this kind of servlet? thanks in advance.
    Regards

  • Calling a servlet from another servlet?

    Hi
    I would like to know that how can I call one Servlet from another Servlet. I have tried getServlet() method of ServletContext but it has been deprecated. I want to call a specific method of the other Servlet, is there any other way?
    Thanks

    I should have seen it from your previous post :(
    Code of Servlet 1:
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws
    ServletException, IOException
    RequestDispatcher rDispatch = null ;
    rDispatch = getServletConfig
    ().getServletContext().getRequestDispatcher
    ("/Servlet2") ;
    rDispatch.forward(request, response) ;
    System.out.println("Back in 1");
    I assume Servlets 1and 2 are in same web app and you've mapped your servlet2 to /Servlet2 in your web.xml
    make it as
    rDispatch = request.getRequestDispatcher("/Servlet2");
    rDispatch.forward(request,response);
    Nothin's wrong with yer servlet2

  • Problem calling servlet from doget method of another servlet

    hi,
    Iam trying to post an html form written in the doGet() method
    of a servlet to pass this information to another servlet's doPost() method. Iam giving the following URL:
    "<FORM ACTION=http://localhost:8080/examples/servlet/UpdateProcessServlet" +
    "METHOD=POST>"
    But its not happening,the error says that "the page cannot be found" The servlet is not getting called at all. would someboy please help me in this regard.
    Thanks

    #1 Iam calling servlet 2 from here
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    session=request.getSession(false);
    out.println
    (ServletUtilities.DOCTYPE +
    "<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN>"+
    "<HTML>" +
    "<BODY>" +
    "<P CLASS=LARGER>" +
    "<FORM ACTION=http://localhost:8080/examples/servlet/UpdateProcessServlet METHOD=POST>"
    "<INPUT TYPE=SUBMIT NAME=submitButton Value=submit>" +
    "</BODY> " +
    "</HTML>" );
    #2 This should get called and print me "Iam in doPost method
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    throws ServletException,IOException
    url = "jdbc:odbc:Resume";
    System.out.println("Iam in doPost method");
    response.setContentType("text/html");
    out = response.getWriter();
    out.println("This is the last servlet for this project:");
    bool=false;
    check=false;
    Thank...:)

  • Passing checkBox value to another servlet

    hey! there,
    I am pretty new for java servlet. I am having trouble for passing the name of the checkbox in another servlet.
    The situation goes like this.
    I have a page where dynamically checkboxes are created based on the number of accounts associated with the user in the database. I have pulled out the information from the database to display in the table where one column is for check box. Now I have to pass the name of the checkbox to the another servlet where I have to ckeck whether the check box value is false or true.
    If the number of check box is static, I could have given the specific name which can be passed to the next servlet easily but the I don't know how many checkbox it comes up in the table.
    Since I am new to Java, I could not figure out how to name that ckeckbox in the page and pass it to the another servlet page.
    Note that the pages are entirely Servlet.
    Any help would be heartly, appriciated

    hi beg,
    One way to this is
    Servlet code
    for i = 1 to noOFUSers
    String x = "<INPUT TYPE=CHECKBOX NAME='user' "+i "
    "put x in screen
    The HTML generated should post to 2nd servlet
    IInd servlet code
    Enumeration paramNames =
    request.getParameterNames();
    while(paramNames.hasMoreElements()) {
    String paramName =
    (String)paramNames.nextElement();
    if(!paramName.startsWith("user"))// same string as
    checkbox name
    continue;
    }else{
    String paramValue =
    request.getParameterValue(paramName);
    / do u r processing on paramValue
    }Another way is to use the same name attribute for all of them
    <INPUT TYPE=CHECKBOX NAME='user' >Then, at the second servlet, call
    String[] users = request.getParameterValues("name");and iterate over the string array.

  • How can send servlet out put to jsp

    Hi friends,
    my problem is ..
    1.In my jsp (let us assume that Test.jsp ) emded tag which emding out put from Servlet.. like
    <embed name="svg" border="1" type="image/svg+xml" width="100%" height="100%" src="http://localhost:8080/demo/Test?"/>
    here the jsp is calling Servlets but at the time display the jsp cannot understand the out put comming from servlets ..
    plz help how can read a Servlet data from JSP
    thanks

    Use <jsp:include page="relative_url_to_servlet"/>. Then have your servlet get the PrintWriter for output from response.getWriter() and you should have it.
    I do this every once in awhile.

  • How to synchronize if one servlet read a file and anothe servlet update the

    How to synchronize if one servlet read a file and anothe servlet update the file at a time?

    Create a class that holds the reference to the file and do the whole file manipulation just in that class. than synchronize the read and write methodes. A reference to this file handler class can be stored to the servlet context in one servlet and read out from the servlet context in the other servlet.

  • Tomcat Servlet: System.out.println in servlet not printing to catalina.out

    Hello friends ,
    When i m using System.out.println() in servlet its o/p should come in catalina.out but its not coming plz help me....one thing more can we replace exixting catalina.out file with new one...
    please Help me soon.
    Thanks

    go to[u] TOMCAT_DIR/config/server.xml.
    Open this xml file and find something like <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="catalina_log." suffix=".txt"
                  timestamp="true"/>and
    <Logger className="org.apache.catalina.logger.FileLogger"
                     directory="logs"  prefix="localhost_log." suffix=".txt"
                timestamp="true"/>You can change the log file name to another one.
    It's much better to use a logger tool like log4j (http://logging.apache.org/log4j/docs/download.html) then using a System.out.println()...
    hope that helps

  • Passing parameter value via href in a servlet to another servlet

    Hi
    I have this issue with passing a value from one servlet to another servlet. the situation is is this.
    i have a servlet tstret.java which say..pulls out all the employee_id(s) from a table and displays it as hyperlinks( using the anchor tag.).
    now when i click on the hyperlink say T001 , The control is passed to another servlet which pulls out all the info about employee id T001.
    the problem i have is in the tstret.java servlet. i am passing the employee_id as a parameter in the href path itself as shown below.
    out.println("<td ><a href=\"http://localhost:7000/servlets-examples/accept_requisition.html?id="+[u]rs.getString(1)[/u]+"\" ><em>"+rs.getString(1)+"</em></a></td>");now if you see the code i am trying to pass the employee_id by attaching it to a variable id and passing it with the url, it gives me a sql exception saying no data found .
    if i pass a string say "rajiv" which i defined at the begining of code then i am able to pass it to the next servlet/html.
    the full code is as follows
    file : tstret.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class tstret extends HttpServlet
         PrintWriter out;
         String[] employee_identity;
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              try
              response.setContentType("text/html");
              out = response.getWriter();
              String session_name="SHOBA";//request.getParameter("session_name");
              out.println("<html><head><title> My Jobs </title></head>");
              out.println("<body bgColor=#ececec leftMargin=10>");
              out.println("<table align=center>");
              out.println("<tr align=center><td><img src=\"http://localhost:7000/servlets-examples/images/topbar.gif\"></td></tr>");
              out.println("<td>Jobs for : "+session_name+"</td>");
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection connection = DriverManager.getConnection("jdbc:odbc:tst","scott","tiger");
              Statement statement=connection.createStatement();
              ResultSet rs= statement.executeQuery("select req_no from require_info where sent_to = " + "\'" + session_name + "\'");
    //          out.println("Jobs for : "+session_name);
              while(rs.next())
              /*     String[] get_id={"shoba","ping","ting","ving"};
                   for(int i=0;i<get_id.length;i++)
                   out.println(" <tr align=\"center\">");
              //     out.println("<td><a href=\"servlet/testhyper\" name="+rs.getString(1)+"><em>"+rs.getString(1)+"</em></a></td>");
                   out.println("<td ><a href=\"http://localhost:7000/servlets-examples/accept_requisition.html?id="+rs.getString(1)+"\" ><em>"+rs.getString(1)+"</em></a></td>");
                   out.println("</tr>");
                   out.println("<br>");
              }catch(SQLException se){out.println("sqlexception"+se);}
              catch(ClassNotFoundException ce){out.println("cnfexception"+ce);}
              out.println("</table></body></html>");
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
              doGet(request, response);
              Can some one help me and see if there is anything i missing or doing wrong.
    thanks in advance

    Try storing the id at the top of the loop, then using that for the URL and the link text, instead of calling rs.getString(1) twice:
      while(rs.next())
        String emp_id = rs.getString(1);
        out.println(" <tr align=\"center\">");
        out.println("<td ><a href=\"accept_requisition.html?id="+emp_id+"\" ><em>"+emp_id+"</em></a></td>");
        out.println("</tr>");
        out.println("<br />");
      }

Maybe you are looking for

  • Customize invoice num of debit memo while doing returning to supplier

    Dear Consultants, We have a requirement to make a customization to modify the invoice number of debit memo which is created when user doing "return to supplier" transaction. My question is: Is there anyway to make this requirement without modify the

  • Preventing Blocked Cost Center in SRM Search help

    Hi All ,   We need to prevent the blocked cost centers  in  the search help  in SRM  . I checked the BADI'S               BBPF4_READ_ON_ENTRY_               BBPF4_READ_ON_EXIT_    and method GET_COSTCENT. but  both of these will not trigger when we g

  • Why do scaled and masked captivate swfs respond to clicks outside the mask? Can it be stopped?

    We load Captivate 3 SWFs at runtime into our own course player, with movieclip.loadmovie. Our player is built with AS2 and published to Flash 8. We publish our Captivate movies to the same specs. Our latest challenge requires scaling and masking the

  • Weird Firefox problem...

    Sooooo Firefox won't load any pages.. Other internet apps work as they should, including browsers, and Firefox works just fine for other users.... What may cause this app not to work for a particular user? I've already trashed it, and re-downloaded a

  • My hp pavilion dv6 laptop hp_ tools e drive is full?

    hey i was wondering why my hp_tools e drive is full, i got this laptop not too long ago in march so it's still fairly new but i keep getting notifications about that drive being full but all it says that i can delete is my already empty recyling bin.