jsp - session management in online exam website using Struts2 -


i creating online assessment application using struts2, jsp , hibernate.

all application parts running perfectly.

my application using concept of session maintain state of user giving exam. , since in case browser shut down, system crash not want user should start 1st question. infact, want user should start left. not able think on this. how test this. there easy way can test concept.

by mistake user close browser, when return he/she start exam he/she left.

he have enter url> enter exam id> continue exam.

for this, using tomcat server session persistency using jdbc store. able store session object in database table session id.

when reopen browser, able session id not able data. application showing nullpointerexception.

public class useraction extends actionsupport{ private string candidateid; private list loaddropdown; //getter setter methods public string user_page1() throws ioexception{ //loading examid in drop down list. loaddropdown=new arraylist();  //getting context object servletcontext ctx=servletactioncontext.getservletcontext();  //creating session object httpsession session = servletactioncontext.getrequest().getsession(false); //showing session id system.out.println("user page 1 :"+session.getid()); if(session.isnew()){ here if user logging first time application should able create new session object , load fresh data. } else { application should show them question left } ... 

so please me on this.

thanks in advance.

ravinderpal singh

there problem approach uses session persistence. if browser configured delete cookies on close or opened in 'private-browsing' mode session id no longer existing sent server!

a better approach track whether user has initiated test directly in database. database can updated whenever user attempts question.

on user login check regarding pending tests can done , user allowed continue if or required.

update : regarding exception itself, stack-trace indeed mentioned jb nizet


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

javascript - Backbone.js getting target attribute -

html - Repeat image to extend header to fill screen -