Passing Objects from Servlet to Servlet

Hei,
how do I pass an object from one servlet to another.. or back to the same again?
I have my servlet and there I want
first create an object, then pass that object for processing and manipulating and then pass it for output of the final result..
How can I send and get the object in a servlet?
Big thx,
LoCal

Hei,
sorry.. maybe I gave to less informations. In fact it's only one servlet...
I can't post the original code but something that makes it clear :)
I wrote the whole project without using Servlet-Technique but normal Java-App. But I designed it so, that I only had to rewrite one class.. and least I thought so.. but now I stuck at this Object-passing problem.
Sorry.. but I'm pretty new to Servlets
Thank you very much in advance for your help.
public class Logger extends HttpServlet {
  private Templates templ = new Templates();
  private Person pers;
  public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String uname = req.getParameter("user");
    String pwd = req.getParameter("pwd");
    String sts = req.getStatus
    PrintWriter out = res.getWriter();
    switch(sts) {
      case 1: out.println(templ.getXHTMLEditPers(pers));
      break;
      case 2: out.println(templ.getXHTMLViewPers(pers));
      break;
      case 3: out.println(templ.getXHTMLView(pers));
      break;
      default: out.println(tmpl.getXHTMLLogin());
  public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
  doGet(req, res);     
}

Similar Messages

  • Pass data from servlet to jsp using sendRedirect

    Hi,
    I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
    Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
    Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me know

    sendRedirect is meant as a true redirect. meaning
    you can use it to redirect to urls not in your
    context....with forward you couldn't pass information
    to jsps/servlets outside your own context.Actually, you can:
    getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
    Brian

  • Passing objects from two servlets residing in  two  servers

    Suppose i need to pass an object from one servlet to another servlet ,that are residing in two servers(Tomcat).How can i achieve this.
    Plz help me in this regard.
    Thanks in Advance......

    Serialize them to XML and send as POST parameter

  • Problem in Passing JTree object from Servlet pgm to browser

    Dear all:
    Can anybody help to resolve the problem - pass the JTree obejct from servlet (Tomcat) to IE 6.0. The JTree oject alway shows invalid charcter in IE. Following is my coding.
    import java.io.*;
    import java.awt.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.swing.*;
    import java.net.URL;
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.tree.*;
    //* Testing1 give it null
    public class SimpleServer extends HttpServlet
    DefaultMutableTreeNode top;
    DefaultMutableTreeNode EX01;
    DefaultMutableTreeNode EX02;
    DefaultMutableTreeNode QB01;
    DefaultMutableTreeNode QB02;
    DefaultMutableTreeNode N2BS;
    DefaultMutableTreeNode N2TS;
    //StringTokenizer st2, st1;
    String query;
    Connection con ;
    Statement statm;
    ResultSet res, backupRes;
    //RowSet res, backupRes;
    TreeSet treeset ;
    String [] tempArray;
    //ServletContext sc ;
    ObjectOutputStream out ;
    DefaultMutableTreeNode temp_node;
         public void doGet(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
    resp.setContentType("text/html");
    // resp.setContentType("application/octet-stream");
    System.out.println("create main node") ;
              out = new ObjectOutputStream(resp.getOutputStream());
              out.writeObject(this.set_NodeMain()); //no DB access,
         public void doPost(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
         try
         System.out.println("doPost " );
         doGet(req,resp);
              finally
         public DefaultMutableTreeNode set_NodeMain()
    top = new DefaultMutableTreeNode("Tandem");
    EX01 = new DefaultMutableTreeNode("EX01");
    EX02 = new DefaultMutableTreeNode("EX02");
    QB01 = new DefaultMutableTreeNode("QB01");
    QB02 = new DefaultMutableTreeNode("QB02");
    N2BS = new DefaultMutableTreeNode("N2BS");
    N2TS = new DefaultMutableTreeNode("N2TS");
    top.add(EX01);
    top.add(EX02);
    top.add(QB01);
    top.add(QB02);
    top.add(N2BS);
    top.add(N2TS);
    return top;
    }

    JMO - I hate seeing things like this in code:
    Just use whitespace to separate the methods.
    You can't just send a JTree to a browser. A browser has no idea how to render a Java object.
    Put that JTree inside an applet and make it part of a JSP. That'll work.
    MOD

  • How to pass objects between servlet services

    I wanted to pass an object from one service to another service and that object must be visible only for these two services. I don't want to use session.setAttribute or session.getAttribute to do this. When I use request.setAttribute and request.getAttribute methods not helping me to do this. Is there a way to do this?
    Between, how these request.setAttribute and request.getAttribute methods useful?
    regds
    -raju

    Actually, I set attribute in one of the service
    methods. Within that service method a form will be
    there. After pressing submit button in that form, the
    other service will be called. Does it mean that both
    the services are not in the same request scope, even
    if they are in the same servlet?They are on different request scopes. Each time the user clicks a link, they make a request to the server. The server processes the request creates a response and send that response back to the client. Once the response it sent (and finished being sent) the request is done with, and anything is request scope goes out of scope. When the user clicks the submit button, a NEW request (and request scope) is made to handle that ...
    Your best bet is to use a session here. It is the easiest way to maintain state between requests. That is what the session is designed for.

  • Best practice from passing messages from servlets

    Is there a best practice for passing user messages (typically errors) back to the page from servlets?
    e.g. http://localhost:4502/content/geometrixx/en.html?message=Some user error message
    Dan

    Well I suppose that answer to that question depends somewhat on your requirements, but I would say using a query string as you have indicated would be less than ideal because the page with the message would not be cached. No depending on your requirements and what sort of message you are passing that might be OK - especially if you message is highly personalized.
    If however you have a limited number of standard messages to display a more common approach is to have each message have it's own page and then to configure the servlet to redirect to the appropriate page based on the desired message.
    If you want the user to end up on the same page they submitted to the servlet from then another common approach would be to have the post to the servlet be AJAX and then display the message client side without having to change the URL.

  • Pass data from servlet to EJB3 and backward

    Hello All,
    The distributed application is being developed by the following scheme:
    J2EE Application Server (JBoss) - Servlet container (JBoss's contained Tomcat) - RIA client (Flex)
    Application server needs to handle client's requests and provide backward connectivity also.
    Servlets in this scheme are required by the BlazeDS library which is implemented as set of servlets handling HTTP requests from the clients.
    This forces us to:
    - invoke EJB from the servlet while handling client's requests.
    - invoke servlet from EJB for the sake of providing the client with urgent messages which need to be displayed immediately.
    The easiest ways to achieve that I am aware of are:
    - servlet invokes EJB via JNDI lookup (inefficient?)
    - EJB invokes servlet by passing HTTP request to web server (inefficient!)
    Is there standard and efficient ways to wire servlets(JSP) and EJB in either directions?
    Thanks,
    Alex.

    Hi Chicon,
    Thanks for advice. Probably I need to add few more words to make the question clearer.
    Chicon wrote:
    It is not the role of an EJB to fire a servlet. EJB's are only modules.
    In your case, the EJB invoked should pass the necessary data to the servlet. From the data it receives, the servlet has either to build and to send the HTML document(or other formats : pdf, txt, xml,...) or to fire the appropriate JSP to the client. The servlet may also call a more specific servlet to do the job, e.g. in a Struts like framework.- Invocation of EJB from servlet is one data flow direction. After EJB is invoked and finished, servlet gets results, makes its own job and sends data to clients either in html or binary AMF (Flex proprietary) format.
    - Invokation of servlet from EJB is another data flow direction. It will be employed, when server decides to inform all interested clients about an urgent event. Client are not asking for that event explicitly, but they are ready for handling such messages from the server.
    Of course, in order to achieve this, there is a need in a channel between server and each client. This is what BlazeDS for.
    The first requirement could be satisfied by either JNDI lookup or (as malrawi proposed) by dependency injection.
    The second one is a little bit harder... It may involve any other mediators, not necessarily the same servlets.
    I am looking for the best suitable solution now.
    Thanks,
    Alex.

  • [urgent[ Passing object from server to the midlet

    I am building a search function for my mobile application..
    I created a servlet "SearchServlet.java" that basically send a query to the dbase to retrieve the values in the database.
    In this servlet, I store the results in an arraylist..
    The servlet works just fine *I've tested it in the browser and accessed it through the local host"..
    The concern now is, what if I need to call the servlet from the midlet application..
    How to pass the object from the server to the midlet?
    Could someone explain to me the mechanism to pass the object?
    What object should be the return value in SearchServlet.java?
    Thank you very much..

    First of all use sober language on forums, its not
    your private forum where you can use your abusive
    language.And even if it is than its not good manners
    to speak in public.Well, quite honestly, my language was not that abusive... I aleady told you that that it's wrong several times... No response on those (at least nothing showing that i would be wrong). And if you keep linking to that code, I find that very anoying.
    Second of all. the try catch block sends response
    back to J2me app request.Its upto developer whatever
    response he wants to send back. There is nothing
    wrong in that.No, all it does it declare a string, nothing more, nothing less. No need to catch any exception!
    third of all if you think that writeUTF method is
    totally wrong, then why dont you show me the
    improved solution or correct solution. After all its
    forum site, if you know the better solution please
    show me rather than always criticising and using
    abusive languages.I told you several times that you should read the api docs! It's all in there and you see why you should not read data with readline() when you write that data with writeUTF(). If you fail to do that, and are not capable to learn from that, then that's your own problem. Sure I could show you what it should be (and I beleive I did more than ones), but what does that teach you? Not a lot! Only to keep coming back here and ask more questions that can be found if you take two minutes of time and read docs or search the internet using google or whatever search engine you like (or even the forum search enigne, since that is also rarely used). I'm not talking about you in particular, but about the general level of the questions asked here. 75% of the answers can be found with a little more effort, and in less time than it would take to wait for someone else to come up with an answer.
    So please, read what writeUTF() does, and you'll understand what's wrong.
    Let me show you:
    Writes a string to the underlying output stream using UTF-8 encoding in a machine-independent manner.
    First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the UTF-8 encoding for the character. If no exception is thrown, the counter written is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of str, and at most two plus thrice the length of str. What does readline() do? It reads UTF-8 text until some endline character. So it will also read the two length bytes of the wirteUTF method. Is this good? No, it's not. If the lengt is to long, it could even insert extra text characters in the line that should not be there, since readline doesn't know anything about the length bytes, and theats them as normal UTF-8 text.
    If you think I dont understand API properly than make
    me explain, thats what forums are for...You never said you didn't understand the api docs... I think they are very clear
    To end it I really doubt that you are developer/
    coder. If you think yourself too perfect please guide
    me.I'm not perfect, I'm just putting effort into finding solution myself.
    If you are going to continue such an attitude I have
    to report to Java forums administrator.I realy don't mind.
    Note to original user who posted this message: I am
    sorry to write such a comment in your thread, but
    "deepspace" user really needs some help.Please, if you want to make a comment, be constuctive. Talking about abusive language... This might be subtle, but it still is abusive! Tell that to all the users I helped already... I bet I'm the most active user here at the moment and I think I helped a whole lot of them very well. Some didn't like my method at first, but in the end, most wil apriciate what I did. I like to let user find out stuff for themselfs, and not give them what they want. They learn much more thay way for sure!

  • ClassCastException while passing object from one context to another

    I am hoping that someone will bear with me as I think it is my knowledge of classloaders that is tripping me up. I am using Spring and have a SecurityContextImpl object that I want to pass from one web app (WA2) to another web app (WA1). In WA2 I do the following:
    ServletContext wa1Context = getServletContext().getContext("WA1");
    wa1Context.setAttribute("SPRING_SECURITY_CONTEXT" , SecurityContextImpl);WA1 then tries to get the SPRING_SECURITY_CONTEXT and cast it to a SecurityContext object. This is where I get the ClassCastException. I have:
    crossContext="true"in my context.xml fragment. My reading tells me that I may be able to get around this by copying all the spring jars into my Tomcat lib folder but I seem to have to copy so much in there (Spring, hibernate, atomikos etc.) that it does not seem to be a good solution; I gave up before copying all the dependencies it asked for. Is there another way around this problem?
    What I really want to do is find an easy way to copy this one object from WA2 into WA1.

    Thanks for taking the time to test this. I also tried with a String and was successful but still cannot get it to work with my SecurityContextImpl. I also tried passing a String wrapped in a custom bean with a single string property. I get the same ClassCastException. I think that using a String works because it is native to the JVM and somehow bypasses the class loading issue but as I say, my knowledge of classloaders is null.
    Here is the exact code I am running in WA1 and WA2:
    In WA2 (context is /forum):
    ServletContext servletContext = httpRequest.getSession().getServletContext().getContext("/");
    servletContext.setAttribute("SPRING_SECURITY_CONTEXT", httpRequest.getSession().getAttribute("SPRING_SECURITY_CONTEXT"));
    logger.debug("It was of type [" + httpRequest.getSession().getAttribute("SPRING_SECURITY_CONTEXT").getClass().getName() + "]");In WA1 (A JSP sitemesh decorator with context "/"):
    Object object = getServletContext().getAttribute("SPRING_SECURITY_CONTEXT");
    System.out.println("IN DECORATOR, OBJECT IS OF TYPE [" + object.getClass().getName() + "]");
    SecurityContext securityContext = (SecurityContext) object;The log output is:
    DEBUG uk.co.prodia.prosoc.security.spring.cas.login.CheckDecoratorKnowsAboutLogin  - It was of type [org.springframework.security.context.SecurityContextImpl]
    IN DECORATOR, OBJECT2 IS OF TYPE [org.springframework.security.context.SecurityContextImpl]

  • Use HTTP Session to pass Object from Web Dynpro for Java to JSP page

    Is it possible to get a handle on the HTTP Session object from within a Web Dynpro application? I want to place a Java object in there that can be retrieved by a JSP page.
    Thanks in advance.

    Hi Tom Cole,
       You can try this. i am not sure if this will work or not.
    HttpServletRequest request = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
    You can also try this.
    IWDRequest mm_request = WDProtocolAdapter.getProtocolAdapter().getRequestObject();
    HttpServletRequest request = (HttpServletRequest)mm_request.getProtocolRequest();
    IWDRequest basically wraps the HttpServletRequest. if you are using NW04s then the getProtocolRequest() may not be available.
    Regards,
    Sanyev

  • Methods of passing parameters from servlets to servlets

    Hi all,
    Im new to Java servlets. After doing some read-up, I understand that parameters can be passed using request.getSession().setAttribute(). The other method is using hidden element as shown below:
    out.println("<form method=POST>");
    out.println("<center>");
    out.println("<input type=submit value=Next>");
    out.println("</center>");
    out.println("<input type=hidden name=passpage value=" + passpage + ">");
    out.println("</form>)");I just want to find whether there is other alternatives and is there any security implications of using hidden element? Any advice will be much appreciated.
    Regards

    HttpServletRequest#setAttribute() is commonly be used to set some object references inside a Servlet before forwarding the request to a JSP. In the JSP you can access it using EL.
    E.g. in a Servlet:String foo = "bar";
    request.setAttribute("name", foo);
    request.getRequestDispatcher("page.jsp").forward(request, response);and in page.jsp:${name} <!-- prints 'bar' -->which only works if you use Servlet 2.4/JSP 2.0. If older, then use JSTL:<c:out value="${name}" /> <!-- prints 'bar' -->HttpServletRequest#getParameter() is commonly used to retrieve parameters from the request. Those parameters can either be set using a query string (e.g. http://foo.com/page.jsp?name1=value1&name2=value2&name3=value3) or by submitting a form with any input fields.
    Having said that, HTML code belongs in a JSP file, not in a Java class. I highly recommend you to reconsider your design.

  • Continuously send serialized objects from servlet

    Hi,
    I'm trying to write a servlet that, once activated, will continuously send objects back to a thread in the client. I'm hoping someone can point me in the right direction. This code works fine if you take out the while(true){...} loops.
    After doing a bit more research, I discovered the OutputObjectStream should be .reset() in order to reset the object map. I tried doing this before the .flush() with no success. The servlet continues to spew out objects, but the client side doesn't even see the first one, hanging on the in = DataInputStream(connection.getInputStream()) line.
    Servlet code:
    public class testStream extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    int[] somedata = new int [1];
    somedata [0] = 1000;
    String contentType =
    "application/x-java-serialized-object";
    response.setContentType(contentType);
    ObjectOutputStream out =
    new ObjectOutputStream(response.getOutputStream());
    while (true) {
    try {
    out.writeObject(somedata );
    System.out.println("Sent " + somedata [0]);
    somedata [0]++;
    } catch(Exception ie) {}
    out.flush();
    Thread.yield();
    out.close(); // unreachable if while loop in place
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    Applet side code:
    * <P>
    * Taken from Core Servlets and JavaServer Pages
    * from Prentice Hall and Sun Microsystems Press,
    * http://www.coreservlets.com/.
    * � 2000 Marty Hall; may be freely used or adapted.
    public class testStream implements Runnable {
    private boolean isDone = false;
    private URL dataURL;
    public testStream(String urlSuffix, URL currentPage) {
    try {
    // Only the URL suffix need be supplied, since
    // the rest of the URL is derived from the current page.
    String protocol = currentPage.getProtocol();
    String host = currentPage.getHost();
    int port = currentPage.getPort();
    dataURL = new URL(protocol, host, port, urlSuffix);
    Thread imageRetriever = new Thread(this);
    imageRetriever.start();
    } catch(MalformedURLException mfe) {
    System.err.println("Bad URL");
    isDone = true;
    public void run() {
    try {
    retrieveImage();
    } catch(IOException ioe) {
    isDone = true; // will never get hit
    public boolean isDone() { // meaningless now with infinite loop
    return(isDone);
    private void retrieveImage() throws IOException {
    URLConnection connection = dataURL.openConnection();
    connection.setUseCaches(false);
    connection.setDoInput(true);
    connection.setDefaultUseCaches (false);
    connection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
    ObjectInputStream in = null;
    try {
    in = new ObjectInputStream(connection.getInputStream());
    } catch (Exception pe) { System.err.println(pe); }
    while (true) {
    // loop forever requesting data
    try {
    // The return type of readObject is Object, so
    // I need a typecast to the actual type.
    int[] someData = (int[]) in.readObject();
    System.err.println(someData[0]);
    } catch(ClassNotFoundException cnfe) {
    System.err.println("received NULL");
    Thread.yield();

    try this: move out.flush() upwards directly after the out.writeObject().
    robert

  • Passing parameter from Servlet to javascript in JSP. Very Urgent - 5 jukes!

    Well my servlet will retrieve questions from database.
    Then the player will answer the question in the JSP and submit the answer to the servlet to process.
    Each time an answer is submitted, or a "Next Question" button is clicked, the countdown time will restart.
    And will reload the page with a new question.
    So how can i do that?
    This is my servlet, JSP, javascript
    =====================================================================
    * Interacts with the player depending on his types of selection and output them
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class GameQuestionServlet extends HttpServlet
         String sSQL = null;
         String sCategory = null;
         String paramName = null;
         User userObject = null;
         Questions gameQsObj = new Questions();
         HttpSession session;
         int cnt = -1;
         int score = 0;
         boolean connected = false;
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              session = request.getSession(false);
              //System.out.println("Testing Score:" + score);
              if(connected == true)
                   Questions object = (Questions)gameQsObj.getQsList().elementAt(cnt);
                   System.out.println("\n" + object.sAns1);
                   System.out.println(object.sAns2);
                   System.out.println(object.sAns3 + "\n");
                   Enumeration enum = request.getParameterNames();
                   while(enum.hasMoreElements())
                        paramName = (String)enum.nextElement();
                        if(paramName.equals("mcq"))
                             System.out.println(request.getParameter("mcq"));
                             score = Integer.parseInt(userObject.score.trim());
                             System.out.println("Player old score: " + score);
                             //Check to see if the selected answer matches the correct answer
                             if((object.sCorrect).equals(request.getParameter("mcq")))
                                  score = score + 10;
                             else
                                  if((object.sCorrect).equals(request.getParameter("mcq")))
                                       score = score + 10;     
                                  else
                                       if((object.sCorrect).equals(request.getParameter("mcq")))
                                            score = score + 10;     
                                       else
                                            score = score - 10;     
              System.out.println("Player current score: " + score);
              else     //will only go into this once
                   userObject = (User)session.getAttribute("user");
                   System.out.println("\n"+userObject.nric);
                   System.out.println(userObject.name);
                   System.out.println(userObject.password);
                   System.out.println(userObject.email);
                   System.out.println(userObject.score+"\n");
                   //depending on user selection
                   sCategory = request.getParameter("qsCategory");
                   sSQL = "SELECT * FROM " + sCategory;
                   gameQsObj.getQuestions(sSQL, sCategory);
                   score = Integer.parseInt(userObject.score);
                   connected = true;
              System.out.println("Connected:" + connected);
              System.out.println("Before:" + userObject.score);
              cnt = cnt + 1; //increment to retrieve next question
              userObject.score = Integer.toString(score);     
              System.out.println("After:" + userObject.score);
              if(cnt < 3) //setting for the number of questions per game.
                   //request.setAttribute("qsCnt", cnt); //count of the question number
                   request.setAttribute("aQs", gameQsObj.getQsList().elementAt(cnt));
                   System.out.println(request.getAttribute("aQs"));
                   System.out.println("This is question number: "+ cnt);
                   getServletConfig().getServletContext().getRequestDispatcher("/JSP/PlayGame.jsp").forward(request, response);
              else
                   //forward to the result page     
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              doPost(request, response);
    <%@ page import="Questions" %>
    <HTML>
         <HEAD>
              <TITLE>Play Game</TITLE>
              <SCRIPT LANGUAGE="JavaScript">
                   var refreshinterval=10
                   var displaycountdown="yes"
                   var starttime
                   var nowtime
                   var reloadseconds=0
                   var secondssinceloaded=0
                   function starttime() {
                        starttime=new Date()
                        starttime=starttime.getTime()
                        countdown()
                   function countdown() {
                        nowtime= new Date()
                        nowtime=nowtime.getTime()
                        secondssinceloaded=(nowtime-starttime)/1000
                        reloadseconds=Math.round(refreshinterval-secondssinceloaded)
                        if (refreshinterval>=secondssinceloaded) {
                   var timer=setTimeout("countdown()",1000)
                             if (displaycountdown=="yes") {
                                  window.status="You have "+reloadseconds+ " second before timeout"
                   else {
                        hide();
                   clearTimeout(timer)
                             //window.location.reload(true)
                   function hide() {
                        //hidelayer
                        if(gameLayers.style.visibility == "visible"){
                             gameLayers.style.visibility = "hidden"
                             oops.style.visibility = "show"
                   window.onload=starttime
              </SCRIPT>
         </HEAD>
         <BODY>
              <FORM METHOD="post" ACTION="http://localhost:8080/Java_Assignment2/servlet/GameQuestionServlet">
                   <DIV ID="oops" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:2; visibility:hidden">
                        Oops! 30 seconds time up!!! <BR><BR>
                        <INPUT TYPE="submit" VALUE="Next Question">
                        <INPUT TYPE="hidden" NAME="nextQs" VALUE="Next Question">
                   </DIV>
                   <DIV ID="gameLayers" STYLE="position:absolute; left:300px; top:30px; width:120px; height:150px; z-index:3; visibility:show">
                   <TABLE BORDER="0">
                        <TR>
                             <TH><BIG>Questions:</BIG></TH>
                        </TR>
    <%
                        Questions aQsObj = (Questions)request.getAttribute("aQs");
                        String aQsBody = aQsObj.sQs;
                        String aQsAns1 = aQsObj.sAns1;
                        String aQsAns2 = aQsObj.sAns2;
                        String aQsAns3 = aQsObj.sAns3;
    %>
                        <TR>
                             <TD><B><%= aQsBody%></B></TD>
                        </TR>
                        <TR>
                             <TD>
                                  <SELECT SIZE="3" NAME="mcq">
                                       <OPTION SELECTED><%= aQsAns1 %></OPTION>
                                       <OPTION><%= aQsAns2 %></OPTION>
                                       <OPTION><%= aQsAns3 %></OPTION>
                                  </SELECT><BR><BR>
                             </TD>
                        </TR>
                        <TR>
                             <TD>
                                  <INPUT TYPE="submit" VALUE="Submit Your Answer">
                                  <INPUT TYPE="hidden" NAME="submitAns" VALUE="Submit Your Answer">
                             </TD>
                        </TR>
                   </TABLE>
                   </DIV>
              </FORM>
         </BODY>
    </HTML>
    This must be answered before 28th of september.
    Please help. It is indeed very urgent.

    this is just a skeleton code.. alot of stuff is not here..
    <FORM name = "form1" action="../servlet/wateverSevlet>
    <input type="text" name="searchStr" size="40">
    <INPUT type="hidden" id=answer name=answer size=7>
    <input type="button" name="button" value="Submit Answer" onClick="javascript:submitCheck(document.form1.searchStr.value);">
    <input type="button" name="button" value="Skip Question" onClick="javascript:submitCheck('skip');">
    </form>
    <SCRIPT LANGUAGE="JavaScript">
    function submitCheck(str)
      form1.answer.value = str
      form1.submit()
    </script>i assuming you are submitting it to the same servlet regardless of whether the user clicks the skip question or the submit question button.

  • Passing data from servlet to excel sheet

    i am learing servlet and JSP.It ll be of great help if i get an idea about passing the data got from JDBC from a servlet to excel sheet.

    Some terms that you can start Googling for:
    JDBC: JDBC is the standard API for Java applications to read/write data from MS Access database (or any other DBMS).
    Jakarta POI: This is one of the tools to generate dynamic Excel files on-the-fly.
    And of course, you're familiar with Servlets, right? ;)

  • Passing objects between Servlets and JSP

    Hi,
    I have passed a ResultSet from a Servlet to JSP using RequestDispatcher forward(). I can access the ResultSet in the JSP page. How can I now pass this ResultSet into another JSP page once the form has been submitted?
    Thanks in advance.

    You should never passing expensive resources like ResultSet around like that. This indicate an open DB connection somewhere while it should already be closed at this stage.
    Read on about the DAO pattern and make use of servlets and beans.

Maybe you are looking for

  • Action method of backing bean called multiple times instead of once.

    Hi, My backing bean has an action method called "saveEquipmentList" that's called when a "Save" button is clicked. The problem is, this method gets executed twice every time the button is clicked so data gets peristed twice, db triggers get executed

  • DELVRY01 via IDoc with batch split

    Hi Experts! Process: -a supplier sends delivery information via EDI to us -the supplier cannot do a batch split, so he sends us the delivery like that Delivery (delivery order, material number, ...) | |-Pos 1 |    | |    |-box 1 (batchnumber) |    |-

  • Mesh tool and pantone colors.

    Hello, I'm trying to make a logo using the mesh tool. I have to use pantone colors, since it will be used on a bussinesscard. Now, I'm experiencing the following problem: I select a darker color on the bottom part of the object, and the gradient is g

  • Album Covers aren't matching up

    The album covers don't match with the correct albums on the iPad. They are correct on the computer in my iTunes account but not on the actual iPad itself. Any ideas on what to do??

  • Automatic shut down after EyeTV automated recording.

    My computer starts up regularly to record something with EyeTV. I'd like it to shut down once the recordings are finished. Some of the recordings happen regularly, and some are one-time-off. Some on the same day, some are the only ones on day, etc.,