Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing a value to a settimeout method using jsp

 
Saumyaraj Zala
Ranch Hand
Posts: 56
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to jsp and servlets and making a Online Examination project. I want a exam(jsp page) to be submitted after a particular time interval(fetched from database). I am not able to get the time from database and the settimeout method is only taking the initial value of the time variable. Please see the code below. Thankyou.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are new to JSP, you are heading down the wrong path right away. Modern JSP has no Java code in the pages. None. You should be putting Java code in servlets and other classes. Within the JSP you should be using only the JSTL (JSP Standard Tag Library) and the EL (Expression Language).

I also recommend reading these articles:
  • The Secret Life of JSPs
  • The Front Man

  • ,
     
    Saumyaraj Zala
    Ranch Hand
    Posts: 56
    Android Java Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks, next time i would follow these practices but for now can you please tell whats getting wrong?
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64700
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Next time is not the correct thine. This time is. Why spend time learning how to do things the wrong way?

    But if you insist on spending time do things poorly, you'll need to be specific about the problem and where it is. There's just too much code in that page to pick it out by inspection.
     
    Saumyaraj Zala
    Ranch Hand
    Posts: 56
    Android Java Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Actually i want the time interval that this setTimeout method will have to be fetched from a table in a database and for that i made a resultset r1 in my code above and then after fetching that time interval i copied that in variable "t" which was fed to my setTimeout method. This is an online test so my setTimeout will have different time interval for each test.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Pie
    Posts: 64700
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Again, that's all stuff that should be handled by the controller and other Java classes.

    What's not working about your timeout now? What HTML is being sent to the browser? That's all that matters. Have you checked it?
     
    Saumyaraj Zala
    Ranch Hand
    Posts: 56
    Android Java Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    There was a silly mistake in my SQL query.
    Thank you for your suggestions. :)
     
    Consider Paul's rocket mass heater.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic