Hello everyone,

I am trying to understand this concept but its truly confusing. I know that javascript is not server side, but I would like to have an effeicient way to retreive a sessions' value, please inform of any methods, I have tried the following

<script>
var MyClientSideVar = <%= Session("MySessionVar")%>;
alert(MyClientSideVar);
</script>

Its still not clear, how would this give me a value of a string stored in a session?

assuming you are using ASP AND the value stored in the session is a string, then WRAP the value you are assigning to the javascript variable in apostrophes:

<%
Session("MySession")="Hello"
%>
<script>
var MyClientSideVar ='<%= Session("MySessionVar")%>[B]'[/B];
alert(MyClientSideVar);
</script>

so, if I wanted to store a string named "first" in my session, should I place first instead of hello?

How flexible will chosing this design be if I wanted to to send this string (first) to an html file? Am I able to achieve this?

The reason why I did not use <%> is because I am trying to have this in my js file, which is in a different file than my html

Thank you for replying

so, if I wanted to store a string named "first" in my session, should I place first instead of hello?

Correct

How flexible will chosing this design be if I wanted to to send this string (first) to an html file? Am I able to achieve this?

I don't understand what exactly you are trying to achive, BUT Session variables are NOT accessible from static pages. Most web servers would treat file named test.html as static page. You would need to use DYNAMIC pages - test.php or test.asp (depending on what you have on the server).

The reason why I did not use <%> is because I am trying to have this in my js file, which is in a different file than my html

The Session variable will NOT be retrievable from a javascript file - ex: test.js
Again, you would need to use server-side script.

What you can do is INSTEAD of serving a test.js:

<script src="test.js"></script>

You can serve directly from an ASP page, BUT the asp page MUST serve the proper MIME type for a javascript file:

<script src="test.asp"></script>

Then in test.asp you send the correct ContentType as well as the "raw" javascript code (without any SCRIPT tags):

<%
Response.ContentType="text/javascript"
%>
var MyClientSideVar ='<%= Session("MySessionVar")%>';
alert(MyClientSideVar);

Again, thanks for your reply.

First, I am using a java web application, not a php application.
Second, I am not really familiar with asp and I dont know whether I am able to have a asp file in a java web application (Im using servlets)
Third, I suppose ajax would be a good way to send data, do you agree that ajax would be much suitable than using sessions

Correct


I don't understand what exactly you are trying to achive, BUT Session variables are NOT accessible from static pages. Most web servers would treat file named test.html as static page. You would need to use DYNAMIC pages - test.php or test.asp (depending on what you have on the server).


The Session variable will NOT be retrievable from a javascript file - ex: test.js
Again, you would need to use server-side script.

What you can do is INSTEAD of serving a test.js:

<script src="test.js"></script>

You can serve directly from an ASP page, BUT the asp page MUST serve the proper MIME type for a javascript file:

<script src="test.asp"></script>

Then in test.asp you send the correct ContentType as well as the "raw" javascript code (without any SCRIPT tags):

<%
Response.ContentType="text/javascript"
%>
var MyClientSideVar ='<%= Session("MySessionVar")%>';
alert(MyClientSideVar);

First, I am using a java web application, not a php application.
Second, I am not really familiar with asp and I dont know whether I am able to have a asp file in a java web application (Im using servlets)

The concepts I discussed earlier still apply. The only thing that is different is your server-side technology. I am not a JSP developer but from what I see at:
http://www.roseindia.net/jsp/ContentTypeAttribute.shtml

the last code block on my previous post would be:

<%@page contentType="text/xml" %>
var MyClientSideVar ='<%= Session("MySessionVar")%>';
alert(MyClientSideVar);

and in your html file you would link to you jsp page (instead of the asp I was referencing as an example):

<script src="test.jsp"></script>

Third, I suppose ajax would be a good way to send data, do you agree that ajax would be much suitable than using sessions

With session you would "retrieve/recall" data, not SEND. So yes, use ajax if you are sending ajax to the server. But if all you are doing is retrieving data, then both will work. If you are using ajax to retrieve data, typically you would send the ajax request after the page has finished loading. IF you use Session, you can have that session info as the page is loading (since you are serving dynamic content).

I think we are getting to the core problem now.

I am not using an html file, I use jsp instead (it is my html files) so, the real question lies in how can I connect the js file to the jsp file

The concepts I discussed earlier still apply. The only thing that is different is your server-side technology. I am not a JSP developer but from what I see at:
http://www.roseindia.net/jsp/ContentTypeAttribute.shtml

the last code block on my previous post would be:

<%@page contentType="text/xml" %>
var MyClientSideVar ='<%= Session("MySessionVar")%>';
alert(MyClientSideVar);

and in your html file you would link to you jsp page (instead of the asp I was referencing as an example):

<script src="test.jsp"></script>

With session you would "retrieve/recall" data, not SEND. So yes, use ajax if you are sending ajax to the server. But if all you are doing is retrieving data, then both will work. If you are using ajax to retrieve data, typically you would send the ajax request after the page has finished loading. IF you use Session, you can have that session info as the page is loading (since you are serving dynamic content).

On my previous post, this: <%@page contentType="text/xml" %> should have been: <%@page contentType="text/javascript" %> Like I said, to "connect" all you have to do in your jsp, as you are serving it, you need to send: <script src="test.jsp"></script> when the browser "sees" that script tag it will make a SEPARATE request to your server to fetch test.jsp. In test.jsp you must send the appropriate mime-type (text/javascript) BEFORE you even begin sending the first line of "PURE js code". By "PURE js code" I meant that your test.jsp may NOT enclose your js code in SCRIPT tags.

Thank you :)

Ill go ahead and program the ajax bit and update on any progress

On my previous post, this: <%@page contentType="text/xml" %> should have been: <%@page contentType="text/javascript" %> Like I said, to "connect" all you have to do in your jsp, as you are serving it, you need to send: <script src="test.jsp"></script> when the browser "sees" that script tag it will make a SEPARATE request to your server to fetch test.jsp. In test.jsp you must send the appropriate mime-type (text/javascript) BEFORE you even begin sending the first line of "PURE js code". By "PURE js code" I meant that your test.jsp may NOT enclose your js code in SCRIPT tags.

Ok so here is what I did,

I used jquery's post method like this:

$document.ready(function){
$post(servlet-name,data-as-string,an-alert-here);

then, in my servlet-page I have

String stage = request.getParameter("stage");

and then I got this error :(
HTTPSTATUS 500
org.apache.jasper.JasperException: java.lang.NullPointerException
because I have a session where my I check if my user == null, I dont understand, It would be wrong to just throw a nullPointer exception, I printed to whole stack trace below

INFO: Launching GlassFish on Apache Felix OSGi platform
Welcome to Felix.
=================
INFO: Started bundle org.glassfish.common.glassfish-mbeanserver [7]
INFO: Started bundle org.glassfish.core.kernel [98]
INFO: Started bundle org.glassfish.common.common-util [80]
INFO: Started bundle GlassFish-Application-Common-Module [65]
INFO: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [65] ]
INFO: registering service = org.apache.felix.framework.StartLevelImpl@e722d0c, contract = org.osgi.service.startlevel.StartLevel, name = null
INFO: registering service = org.apache.felix.framework.PackageAdminImpl@4ef888ea, contract = org.osgi.service.packageadmin.PackageAdmin, name = null
INFO: Started bundle org.glassfish.branding.branding [29]
INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started
no resource bundle found for version, using default GlassFish version
INFO: Started bundle org.glassfish.common.internal-api [84]
INFO: Started bundle org.glassfish.admin.config-api [72]
INFO: Started bundle org.glassfish.registration.glassfish-registration [94]
INFO: Started bundle org.glassfish.deployment.deployment-autodeploy [58]
INFO: Started bundle org.glassfish.deployment.deployment-common [90]
INFO: Started bundle org.glassfish.flashlight.flashlight-framework [93]
INFO: Listening on port 8080
INFO: Network listener http-listener-2 on port 8181 disabled per domain.xml
INFO: Listening on port 4848
INFO: Started bundle org.glassfish.common.container-common [101]
INFO: The Admin Console Web Application has been downloaded.
INFO: Started bundle org.glassfish.common.glassfish-naming [86]
INFO: Started bundle org.glassfish.common.glassfish-api [102]
INFO: Started bundle org.glassfish.persistence.jpa-connector [62]
INFO: Started bundle org.glassfish.connectors.connectors-runtime [23]
INFO: Started bundle org.glassfish.scripting.gf-jruby-connector [57]
INFO: Started bundle org.glassfish.web.gf-web-connector [119]
INFO: Started bundle org.glassfish.ejb.gf-ejb-connector [108]
INFO: Started bundle org.glassfish.security.security [60]
INFO: security.secmgroff
INFO: Started bundle org.glassfish.security.securitycommon [19]
INFO: Security startup service called
INFO: Started bundle org.glassfish.transaction.jta [54]
INFO: Started bundle org.glassfish.security.realms [70]
INFO: Security service(s) started successfully....
INFO: registering service = org.glassfish.web.DirContextURLStreamHandlerService@a56b3bc, contract = org.osgi.service.url.URLStreamHandlerService, name = null
INFO: Started bundle org.glassfish.web.web-glue [111]
INFO: Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://aboodi.home:8686/jmxrmi
INFO: Started bundle org.glassfish.ejb.ejb-container [109]
INFO: Created HTTP listener http-listener-1 on port 8080
INFO: Created HTTP listener admin-listener on port 4848
INFO: Created virtual server server
INFO: Created virtual server __asadmin
INFO: Started bundle org.glassfish.deployment.dol [8]
INFO: Created SingletonHandler......
INFO: Started bundle org.glassfish.web.web-core [128]
INFO: Dual registration of jndi stream handler: factory already defined
INFO: Unknown loader 111.0 class org.apache.felix.framework.searchpolicy.ContentClassLoader
INFO: Started bundle org.glassfish.web.jstl-connector [117]
INFO: Started bundle org.glassfish.web.jsf-connector [124]
INFO: Started bundle org.glassfish.transaction.jts [61]
INFO: Using com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate as the delegate
INFO: Started bundle org.glassfish.connectors.work-management [34]
INFO: Started bundle org.glassfish.common.glassfish-ee-api [47]
INFO: Started bundle org.glassfish.connectors.connectors-internal-api [106]
INFO: policy.loading
INFO: Started bundle org.glassfish.web.war-util [120]
INFO: Started bundle org.glassfish.security.websecurity [113]
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: PWC1412: WebModule[/Project] ServletContext.log():Initializing Spring root WebApplicationContext
INFO: Root WebApplicationContext: initialization started
INFO: Refreshing Root WebApplicationContext: startup date [Fri Nov 19 21:35:43 GMT 2010]; root of context hierarchy
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5240d72: defining beans []; root of factory hierarchy
INFO: Root WebApplicationContext: initialization completed in 1405 ms
INFO: PWC1412: WebModule[/Project] ServletContext.log():Initializing Spring FrameworkServlet 'dispatcher'
INFO: FrameworkServlet 'dispatcher': initialization started
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Fri Nov 19 21:35:44 GMT 2010]; parent: Root WebApplicationContext
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2569bcfe: defining beans [org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0,urlMapping,viewResolver,indexController]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@5240d72
INFO: Mapped URL path [/index.htm] onto handler [org.springframework.web.servlet.mvc.ParameterizableViewController@4efe2553]
INFO: FrameworkServlet 'dispatcher': initialization completed in 1629 ms
INFO: Loading application Project at /Project
INFO: Loading Project Application done is 25403 ms
WARNING: Cannot load student reason : student
java.lang.ClassNotFoundException: student
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
        at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.getElements(ModuleScanner.java:189)
        at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:436)
        at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:348)
        at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:320)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:211)
        at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:143)
        at org.glassfish.javaee.core.deployment.JavaEEDeployer.parseModuleMetaData(JavaEEDeployer.java:231)
        at com.sun.enterprise.web.WebDeployer.parseModuleMetaData(WebDeployer.java:110)
        at org.glassfish.javaee.core.deployment.JavaEEDeployer.loadMetaData(JavaEEDeployer.java:157)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:429)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:173)
        at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:260)
        at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:97)
        at com.sun.enterprise.v3.server.ApplicationLoaderInjector.postConstruct(ApplicationLoaderInjector.java:61)
        at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
        at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:87)
        at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
        at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
        at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
        at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
        at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:203)
        at com.sun.enterprise.v3.server.AppServerStartup$1.run(AppServerStartup.java:116)
WARNING: Cannot load student reason : student
java.lang.ClassNotFoundException: student
        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
        at com.sun.enterprise.deployment.annotation.impl.ModuleScanner.getElements(ModuleScanner.java:189)
        at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:127)
        at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:476)
        at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:348)
        at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:320)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:211)
        at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:143)
        at org.glassfish.javaee.core.deployment.JavaEEDeployer.parseModuleMetaData(JavaEEDeployer.java:231)
        at com.sun.enterprise.web.WebDeployer.parseModuleMetaData(WebDeployer.java:110)
        at org.glassfish.javaee.core.deployment.JavaEEDeployer.loadMetaData(JavaEEDeployer.java:157)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.prepare(ApplicationLifecycle.java:429)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:173)
        at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:260)
        at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:97)
        at com.sun.enterprise.v3.server.ApplicationLoaderInjector.postConstruct(ApplicationLoaderInjector.java:61)
        at com.sun.hk2.component.AbstractWombImpl.inject(AbstractWombImpl.java:150)
        at com.sun.hk2.component.ConstructorWomb$1.run(ConstructorWomb.java:90)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.hk2.component.ConstructorWomb.initialize(ConstructorWomb.java:87)
        at com.sun.hk2.component.AbstractWombImpl.get(AbstractWombImpl.java:75)
        at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:58)
        at com.sun.hk2.component.LazyInhabitant.get(LazyInhabitant.java:107)
        at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:60)
        at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:203)
        at com.sun.enterprise.v3.server.AppServerStartup$1.run(AppServerStartup.java:116)
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application servlets at /servlets
INFO: Loading servlets Application done is 2605 ms
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Loading Lambda Application done is 3169 ms
INFO: GlassFish v3 Prelude startup time : Felix(13759ms) startup services(34884ms) total(48643ms)
SEVERE: java_security.expired_certificate
INFO: Those two passwords do not match please enter again
INFO: classLoader = WebappClassLoader
  delegate: true
  repositories:
    WEB-INF/classes/
----------> Parent Classloader:
org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce
INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@53d8631f
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Deployment of Lambda done is 4258 ms
INFO: classLoader = WebappClassLoader
  delegate: true
  repositories:
    WEB-INF/classes/
----------> Parent Classloader:
org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce
INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@53d8631f
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Deployment of Lambda done is 694 ms
INFO: classLoader = WebappClassLoader
  delegate: true
  repositories:
    WEB-INF/classes/
----------> Parent Classloader:
org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce
INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@53d8631f
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Deployment of Lambda done is 2154 ms
INFO: classLoader = WebappClassLoader
  delegate: true
  repositories:
    WEB-INF/classes/
----------> Parent Classloader:
org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce
INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@53d8631f
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Deployment of Lambda done is 1697 ms
SEVERE: StandardWrapperValve[updateStage]: PWC1406: Servlet.service() for servlet updateStage threw exception
java.lang.IllegalStateException
        at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:530)
        at updateStage.doPost(updateStage.java:85)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
        at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
        at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
        at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
        at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
        at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
        at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
        at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
SEVERE: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
        at org.apache.jsp.studentPortal_jsp._jspService(studentPortal_jsp.java from :66)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:366)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
        at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
        at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
        at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
        at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
        at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
        at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
        at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
INFO: classLoader = WebappClassLoader
  delegate: true
  repositories:
    WEB-INF/classes/
----------> Parent Classloader:
org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce
INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@53d8631f
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Deployment of Lambda done is 4176 ms
INFO: classLoader = WebappClassLoader
  delegate: true
  repositories:
    WEB-INF/classes/
----------> Parent Classloader:
org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce
INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@53d8631f
INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@2ae0cbce class org.glassfish.internal.api.DelegatingClassLoader
INFO: Loading application Lambda at /Lambda-2
INFO: Deployment of Lambda done is 1347 ms
INFO: There is a problem here
SEVERE: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
        at org.apache.jsp.studentPortal_jsp._jspService(studentPortal_jsp.java from :66)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:109)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:366)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
        at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
        at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
        at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
        at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
        at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
        at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
        at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
SEVERE: null
org.postgresql.util.PSQLException: The column index is out of range: 2, number of columns: 1.
        at org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:53)
        at org.postgresql.core.v3.SimpleParameterList.setNull(SimpleParameterList.java:130)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1273)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.setString(AbstractJdbc2Statement.java:1262)
        at updateStage.doPost(updateStage.java:108)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:431)
        at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
        at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
        at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
        at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
        at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
        at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
        at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
        at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
        at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
        at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
        at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)

On my previous post, this: <%@page contentType="text/xml" %> should have been: <%@page contentType="text/javascript" %> Like I said, to "connect" all you have to do in your jsp, as you are serving it, you need to send: <script src="test.jsp"></script> when the browser "sees" that script tag it will make a SEPARATE request to your server to fetch test.jsp. In test.jsp you must send the appropriate mime-type (text/javascript) BEFORE you even begin sending the first line of "PURE js code". By "PURE js code" I meant that your test.jsp may NOT enclose your js code in SCRIPT tags.

that does not look like jquery. If that is EXACTLY what you used then it's wrong.

As for the JSP part, I can't help you there. I am not a jsp developer.

That is not exactly what I have in my code, its basically this

$(document).ready(function() {
                    $.post("updateStage", Stage, function(data) {
                        alert("stage loaded perfectly" + data);
                    });

                });

that does not look like jquery. If that is EXACTLY what you used then it's wrong.

As for the JSP part, I can't help you there. I am not a jsp developer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.