How can i redirect to another JSP page automatically after some event

I am developing a Tic-Tac-Toe game which can be played between two players who are on two different machines.
When the first player comes to the Welcome page he will redirected to a Waiting Page when he clicks on the 'Start' button.
When the second player comes to the Welcome page he will be redirected directly to the Game page, on clicking the 'Start' button.
So how can i redirect the first player to the Game page after the second player is available for the game.
And if i want to manage multiple instances of my game how can i do that//
I am using JSP, javascript and MySQL for developing my project, and I am new to all these tools, but i would still like to carry on with all these only

This is a bit of a challenge because of the nature of the web. Generally the web is "pull only" meaning that the browser has to initiate any interactions - the server can't push data to the browser if it wasn't asked to.
The easiest way to solve this is using AJAX via JavaScript to periodically poll the server for any status changes. There are other ways (the Comet protocol is one) but they start to get a bit difficult and are still a bit new and not completely supported in a standards way. And to be honest they are still basically polling though in a more efficient way.
Are you using a JavaScript framework? Most of the JavaScript frameworks that I've used have built in support for polling in the background. You'd have to have the JSP/servlet side be able to handle these polling requests from the browser and, when another person joins the game, the server indicates that and sends that back to the browser.
As far as multiple instances I would have the server automatically pair up users as needed. So when the first player arrives he has to wait for another player. When the second player arrives a new game is created for those two players. Now a third player arrives and waits until a fourth player shows up. When player 4 joins another separate game is created. Presumably the conversation between the browser and the server will need to include a "game number" or other unique number so that the server can keep track of the games.

Similar Messages

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • How can I link to a jsp page from another jsp page within websphere portal?

    Afternoon all,
    I have a websphere portlet which displays a jsp page. I want to put a hyperlink on the jsp page which when clicked will open another jsp page.
    Does anyone know how to do this?
    Thanks,
    Alex

    The anchor tag is the correct one for generating clickable links.
    <jsp:forward> is for transferring control at the server end. Its when you decide to change which page you want to show the user. ie check user is logged in. If not then forward them to login page, else display current page.
    I tried that. It does open the jsp page
    but the place and page links in the portal theme get screwed up.Whats mucked up about them? Do they point where they shouldn't?
    You might try using a <base> tag to set where relative links are resolved from.
    Cheers,
    evnafets

  • How can you opening the tree.jsp page to a specific folder?

    I am trying to pass a query string into the viewer.jsp page so that I can open the appropriate folder relating to that query string. I can't find a way to do this as of yet. A lot of the code doing the work is only .class files so it is challenging.
    If you have any ideas as to how to begin to tackle this problem please let me know. Basically the querystring would contain the folder I want the tree to open to.
    Thanks,
    Simon

    See:
    *https://mike.kaply.com/2012/02/09/integrating-add-ons-into-firefox/

  • How can I navigate to a new page when after-submit process running proc

    I have a long running procedure and would like to provide the users with an animated gif to indicate progress that updates a description line to indicate the current step in the process.
    Currently I have a couple pages in this application in which a stored procedure in a package is called which performs a long-running process which updates progress in a table. These processes have a single parameter argument. In these cases I call the procedure via the Job Scheduler as part of my After-Submit process and the page navigation jumps to another page which shows a graphical representation of % complete based on the progress updates in the table and refreshes itself every 5 seconds until the job is complete. This works fine.
    I am now running into an issue where I have a more complex set of processes, with a number of parameters. To resolve this I used the same process as above, however, I first check to see if the process exists in the Job Scheduler, if not I create it. I then set all of the parameters and tell the job scheduler to execute the procedure. This should work similar to the process I am running on the other pages, however, in this page where I have multiple parameters and send an execute command rather than an execute immediate on job creation, the system runs the entire job prior to running the page branch, as a result the end user is stuck on a hanging page with no user feedback for two minutes after pressing submit.
    I am looking for how to call the procedure and have the branch execute so a progress screen can be viewed. I am not committed to the use of the job scheduler if there is a better way.
    Any help is greatly appreciated.

    The process involves
    (1) a detail table filled with phone usage data, approximately 175,000 records per month.
    (2) a table that stores what various combinations of codes in the detail table translate to for types of calls or data transmissions
    (3) a summary table for the months calls and billing
    (4) the E-Business Suite.
    (5) A GTT for temporary crossreference storage
    (6) A GTT for reporting data
    I have a parameter page where the user selects what data they are looking for and then submits it to generate the report.
    The generation of data is a four step process.
    (A) Retrieve the Code Combination ID's for the phone usage specified in the parameters from the summary billing table(1) into a GTT(5)
    (B) Query the department and Account Code Block Details from E-Business Suite(3) (using dblink) for the CCID's in step one and add to the GTT(5)
    (C) Run a query which uses the detail table(1), a function against the crossref table(2), and the crossreference GTT(5) to create the output in the report GTT(6)
    (D) An ApEx page process that counts the output and returns to a page without Export to Excel for over 65000 records or with Export for under.
    The parameter page is an ApEx page with some text fields, a couple date fields, and some checkboxes. An after submit process calls a packaged procedure which calls separate procedures for (A), (B), and (C), the page then branches to a page that shows an animated gif and current step of the process {this is what is not working right now}. Once the task completes this page branches as per (D) to a page that shows all the contents of the GTT report(6).
    The process works successfully with the exception that instead of going to a page to show the process the system simply hangs on the parameter page after the submit is pressed until the processing is done and then goes to the processing page just long enough to branch to the report page.
    I am beginning to think that I should alter the design to not use the GTT, but include the username as a field in the output table with a binary index on it for speed so that I can use the job scheduler to run a separate session and hence enable the processing page. The processing page is important as the query can take anywhere from 2 minutes to 2 hours to generate the report depending upon the parameters.

  • How to Link another JSP Page in the same portal component

    Hi Guys,
      I am a new guy to SAP, currently, I want to add href link to another JSP in the same component, so I used <a href="<%=webpath%>/jsp/AboutPage.jsp">, but obviously, the link can not display target page due to privilege restriction, does anyone know how to resolve this problem? thanks very much!
      Best Regards
      James

    Thanks srinivas,
       Sorry for late response, too busy yesterday.
       Currently, I want to create a URL link in the page which links another JSP page in the same portal component, but the problem is this JSP page is under PORTAL-INF folder, so due to privilege problem, I can not create the link like the following:
    <a href="jsp/test.jsp">Link</a>
       I konw if I move test.jsp out of folder PORTAL-INF, the above way should work, but then, I found the JSP page can not access componentRequest and get resource bundle object.
      Am I clear, please let me know, thanks!
    Regards.
    James

  • How we can generate dynamic menu in jsp page

    Hi all,
    how we can generate dynamic menu in jsp page.
    Thanks
    Manjinder

    by reading more about them on the web or in a good book, OR BY HIRING SOMEBODY TO DO SO. ;)

  • HOW to send a value to another jsp page

    HOW to send a value to another jsp page, like user name in one jsp page to another jsp page

    In the most simplest form...
    // pageA.jsp
    <html>
    <body>
    <form action="pageB.jsp" method="post">
    <b>First Name:</b> <input type="text" name="FNAME" value="Joe">
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    // pageB.jsp
    <html>
    <body>
    <b>Name:<b> <%=request.getParameter("FNAME")%>
    </body>
    </html>

  • How to Open another jsp page from jsp page

    Hi,
    I am new to JSP. I need help to handle issue given below:
    I have created one JSP Page for Login which contains Username and Password with a Submit Button. Once user inputs UserName and Password and Press Submit Button, It calls another JSP Page "Validate_login"
    Validate_Login JSP does a JDBC call to Databse and validate User Name and Password. Now i want to open a "Employee.jsp" page if Username and Password matches with the one in database.
    Pls advice what function or tag should i use to open this page in If (condition) true section.. I tried Window.open but it return back with error.

    I tried with the function suggested by Doly. But nothing is happening. It doesn't redirect to any page. only a blank page comes.
    here is complete code . pls correct me if i am wrong somewhere.
    this is code of Validate_Login.jsp page which is invoked when user press login button on login.jsp.
    my purpose is to validate username and password from database and redirect to employee.jsp if it is ok else back to login.jsp
    here is source of Validate_login.jsp
    =============================================================
    <%@ page language="java" import="java.sql.*" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Validate Login</title>
    </head>
    <body>
    <%
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String viewPATH = "c:/MyData.mdb";
    String dsnPATH = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb); " +
    "DBQ="+viewPATH+"; " +
    "UserCommitSync=Yes; " +
    "Threads=3; " +
    "SafeTransactions=0; " +
    "PageTimeout=5; " +
    "MaxScanRows=8; " +
    "MaxBufferSize=2048; " +
    "DriverId=281; " +
    "DefaultDir=C:/ProgramFiles/CommonFiles/ODBC/DataSources";
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    try
         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         conn = DriverManager.getConnection(dsnPATH, "", "");
         stmt = conn.createStatement();
    rs= stmt.executeQuery("SELECT * FROM Employee where emp_id='"+username+"'");
    while(rs.next())
    String pass = rs.getString("password");
    if (pass.equals(password))
    { response.sendRedirect("Employee.jsp");}
    else
    { response.sendRedirect("login.jsp");}
    catch(Exception e)
    e.printStackTrace();
    finally
         if(stmt!=null) stmt.close();
         if(conn!=null) conn.close();
    %>
    </body>
    </html>

  • How can I achieve to another PC's firefox current loading page, if that PC is already unable to use/activiate anymore?

    My PC do not operate/works anymore. I am intending to donate it to others, but reserving the hard-disk(in which all data still in).And I am retrieving the data to the hard-disk via an USB cable. How can I get the current loading pages, as well as other bookmarks, plug-ins in this PC hard-disk? I can only load the data by MY COMPUTER. Where can I locate the above-mentioned material in the specific folder?

    Note that if you give the PC to someone else with this same hard drive that you should do a secure wipe to overwrite all data stored on this drive securely.<br />
    Deleting files is not enough as you only need to use an undelete utility (e.g. Recuva) to recover all data.
    *http://www.thefreecountry.com/security/securedelete.shtml
    *https://support.mozilla.org/kb/Recovering+important+data+from+an+old+profile
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • How can i set a global error page for all error cod

    how can i set a global error page for all error code?
    i don't want to leave a long list in the web.xml file.could any one help me?
    thanks

    If u have a common Error JSP named as ErrorPage.jsp
    You need to have the following piece of code in the JSP as :
    <%@ page isErrorPage ="true"%>
    This makes it as the Common Error Page for the Application. Now all you need to do is from other JSP's throw the Exception to teh container. The container will redirect to this Page and process accordingly.
    Thanks and regards,
    Pazhanikanthan. P

  • Passing values to current jsp page to another jsp page in ADF

    Hi All,
    In my adf application i want to get the appropriate field value of selected row and i want to send that value to the another jsp page from curent jsp page when will we click on button or link.How can i do this.Please give me your valuable suggestions.I'm using jdeveloper 11.1.1.5 version. Thanks!

    Hi,
    Thanks for the reply. I didnt understand the execution of the process. can you please send any sample for text like hello world is passing to second jsp page. or any simple sample?

  • Is it possible to pass selected value from one jsp to another jsp page?

    In my welcome page(in jsp), if the user is selecting some values, is it possible to pass those values to another jsp page and display?
    If yes, how can it be done?
    please help..

    Yes, you would have to make the motion from one page to the next submit a form. Then on the second JSP you can use request.getParameter("nameOfInputField") to get the value the user selected.

  • How can I open the EP login page in the same pop-up window?

    is it possible for me to using / only one window(Browser) pop-up to EP Page(Login or iView...).
    In the firs general html page I create a EP login page link action[eg. "window.open('url', 'target_name')"],
    but always launching new pop-up window(Browser).
    How can I open the EP login page in the only one window(pop-up)?
    Could anybody help me by giving suggestion and codding?
    Thanks,
    jin.

    Hi,
    if you want to redirect the root of portal system (http://portal/) to the login page, edit the
    file and change the body tag as follow:
    \usr\sap\J2E\JC00\j2ee\cluster\server0\apps\sap.com\com.sap.engine.docs.examples\servlet_jsp\_default\root\index.html
    <body onload="location.replace('irj/portal' + document.location.search)"></body>

  • How to enable the EL in jsp page

    hi can u tell 'how to enable the EL in jsp page'?

    *I am getting below exception in tomcat when i inclued +<%@ page isScriptingEnabled="true" isELEnabled="true"%>+*
    org.apache.jasper.JasperException: /index.jsp(1,1) Page directive has invalid attribute: isScriptingEnabled
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
         org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:311)
         org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:106)
         org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Validator.validate(Validator.java:1700)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Maybe you are looking for

  • Dynamic column in ALV Report

    Hi, We need to display amount fields in the ALV and that fields should be able to display both 3 decimals or 2 decimals at the same time.When we refer this as a character field it is not allowed for totals/subtotals . if we refer it as 3 decimals ,it

  • Currency converting in 5 decimal place, time of posting in foreign currency

    Hi I am facing one problem at the time of posting of advance with bank charges in foreign currency USD. While i am trying to post advance to vendor with T code - F-48 with USD currency i mention the exchnage rate 51.56 , bank charges 500 in local cur

  • Art board size

    Hi I need to make a billboard which is around 500 inches long. But, the largest size Illustrator documents go is around half that... Since my printer requires that this job be done in either Photoshop, Illustrator or Quark... What do I do? Anyone got

  • Another MAX()  function question...

    Help was provided earlier for a question I had regarding use of the MAX function... This also pertains to that. I have two tables, employee and movie. I want to find the name of the employee who has entered the most amount of movies into our database

  • Best way to import the word or PDF file

    Hi All, I am going to start a new project in Robohelp (7.0). Presently i am working on the evaluation version, but will get the original copy soon. All the existing documents are Pagemaker files and i need to copy them into Robohelp project. I have n