Skip to main content



      Home
Home » Archived » BIRT » getting objects from the session
getting objects from the session [message #145077] Fri, 17 March 2006 09:47 Go to next message
Eclipse UserFriend
Hi. I'm trying to access objects from the session.

resultVo = (DisplayVo)
reportContext.getHttpServletRequest().getAttribute('myDis'); //myDis is
DisplayVo object that is in the session
this.valueExpr=resultVo.getFirstString();
/*getFristString is a method that returns a string*/

the errors:
Error0 : Error.ScriptEvaluationError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are
errors evaluating script "var resultVo=new Packages.DisplayVo();". at
org.eclipse.birt.report.engine.executor.ExecutionContext.eva luate(ExecutionContext.java:508)
at
org.eclipse.birt.report.engine.executor.ExecutionContext.eva luate(ExecutionContext.java:471)
at
org.eclipse.birt.report.engine.data.dte.DteDataEngine.evalua te(DteDataEngine.java:321)

anyone can help me please? the report and the class file DisplayVo are in
the same project and I have copied the DisplayVo.class in C:\Program
Files\MyEclipse\eclipse\plugins\org.eclipse.birt.report.view er_2.0.1\birt\WEB-INF\classes

Thank you and have a Happy Saint Patrick's Day!

Cristian
Re: getting objects from the session [message #145092 is a reply to message #145077] Fri, 17 March 2006 10:16 Go to previous messageGo to next message
Eclipse UserFriend
Cristian,

Where are you doing this:
var resultVo=new Packages.DisplayVo();

Does this class depend on anything else?

Jason

"Cristian" <ceol.gael@gmail.com> wrote in message
news:e6334b53a7fa74daa4c2b2de607c5e14$1@www.eclipse.org...
> Hi. I'm trying to access objects from the session.
>
> resultVo = (DisplayVo)
> reportContext.getHttpServletRequest().getAttribute('myDis'); //myDis is
> DisplayVo object that is in the session
> this.valueExpr=resultVo.getFirstString(); /*getFristString is a method
> that returns a string*/
>
> the errors:
> Error0 : Error.ScriptEvaluationError ( 1 time(s) )
> detail : org.eclipse.birt.report.engine.api.EngineException: There are
> errors evaluating script "var resultVo=new Packages.DisplayVo();". at
> org.eclipse.birt.report.engine.executor.ExecutionContext.eva luate(ExecutionContext.java:508)
> at
> org.eclipse.birt.report.engine.executor.ExecutionContext.eva luate(ExecutionContext.java:471)
> at
> org.eclipse.birt.report.engine.data.dte.DteDataEngine.evalua te(DteDataEngine.java:321)
>
> anyone can help me please? the report and the class file DisplayVo are in
> the same project and I have copied the DisplayVo.class in C:\Program
> Files\MyEclipse\eclipse\plugins\org.eclipse.birt.report.view er_2.0.1\birt\WEB-INF\classes
>
> Thank you and have a Happy Saint Patrick's Day!
>
> Cristian
>
Re: getting objects from the session [message #145397 is a reply to message #145092] Fri, 17 March 2006 10:36 Go to previous messageGo to next message
Eclipse UserFriend
hi Jason. Here's my class:

public class DisplayVo implements java.io.Serializable{
private String firstString;


public void setFirstString(String firstString) {
this.firstString = firstString;
}
public String getFirstString() {
return firstString;
}
}

I'm trying to initialize the object inside the expression builder of a
data object. i made that work finnaly but i can't retrieve the data from
the session. it seams that
var frame2=(DisplayVo)
reportContext.getHttpServletRequest().getAttribute('myDis');
doesn't return me no object, the error looks like

Error0 : Error.ScriptEvaluationError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: There are
errors evaluating script "var frame2=(DisplayVo)
reportContext.getHttpServletRequest().getAttribute( 'myDis' );". at
org.eclipse.birt.report.engine.executor.ExecutionContext.eva luate(ExecutionContext.java:508)

I checked the object myDis in the session with a simple jsp and it is (i
put it previously with a servlet)

Cristian
Re: getting objects from the session [message #145405 is a reply to message #145397] Fri, 17 March 2006 10:55 Go to previous messageGo to next message
Eclipse UserFriend
Cristian,
You could use global variables for this or app context but if you want it in
session do this

reportContext.getHttpServletRequest().getSession().setAttrib ute( "myDis",
disinstance);

to get it later
xyz =
reportContext.getHttpServletRequest().getSession().getAttrib ute( "myDis");

Make sure you verify the order when you set it. Make sure that control is
called before the get.

Jason

"Cristian" <ceol.gael@gmail.com> wrote in message
news:26cc769df1beb39e88df8b28c9005fda$1@www.eclipse.org...
> hi Jason. Here's my class:
>
> public class DisplayVo implements java.io.Serializable{
> private String firstString;
>
>
> public void setFirstString(String firstString) {
> this.firstString = firstString;
> }
> public String getFirstString() {
> return firstString;
> }
> }
>
> I'm trying to initialize the object inside the expression builder of a
> data object. i made that work finnaly but i can't retrieve the data from
> the session. it seams that var frame2=(DisplayVo)
> reportContext.getHttpServletRequest().getAttribute('myDis'); doesn't
> return me no object, the error looks like
> Error0 : Error.ScriptEvaluationError ( 1 time(s) )
> detail : org.eclipse.birt.report.engine.api.EngineException: There are
> errors evaluating script "var frame2=(DisplayVo)
> reportContext.getHttpServletRequest().getAttribute( 'myDis' );". at
> org.eclipse.birt.report.engine.executor.ExecutionContext.eva luate(ExecutionContext.java:508)
>
> I checked the object myDis in the session with a simple jsp and it is (i
> put it previously with a servlet)
>
> Cristian
>
Re: getting objects from the session [message #145429 is a reply to message #145405] Fri, 17 March 2006 11:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi. Between the reports it's working, but not from a servlet to a report.

Here's my sevlet:

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.xxxx.vo.DisplayVo;

public class TestingServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

DisplayVo myDisplay = new DisplayVo();
myDisplay.setFirstString("first 111 from servlet");
HttpSession mySession = request.getSession();
mySession.setAttribute("myDis", myDisplay);
}
}

Thank you,
Cristian
Re: getting objects from the session [message #145455 is a reply to message #145405] Fri, 17 March 2006 12:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi. Between the servlets it's working and also between the reports, but
not between a servlet and a report. Does anybody have any idea why?

Thank you,
Cristian
Re: getting objects from the session [message #145507 is a reply to message #145455] Fri, 17 March 2006 13:14 Go to previous messageGo to next message
Eclipse UserFriend
Cristian,

I modified the BIRT viewer index.jsp and added as session var at the top of
the file

<%
session.setAttribute("testSession", "Test My Session");
%>

in my report I put a data element with the following expression

ab=reportContext.getHttpServletRequest().getSession().getAtt ribute( "testSession");


Make sure you put &__overwrite=true at the end of your URL for running the
report. Also make sure JSP gets reloaded.

Jason

"Cristian" <ceol.gael@gmail.com> wrote in message
news:52ed5bc99e873ab92e77541c2c0fac6c$1@www.eclipse.org...
> Hi. Between the servlets it's working and also between the reports, but
> not between a servlet and a report. Does anybody have any idea why?
>
> Thank you,
> Cristian
>
Re: getting objects from the session [message #145516 is a reply to message #145405] Fri, 17 March 2006 13:22 Go to previous messageGo to next message
Eclipse UserFriend
I've tryed several scenarios:

1. I start with a servlet that stores an object into session, then I
continue with a report that tryies to get that object from the session.
From the report I go to a JSP file that tryies also to get that object
from the session. Results: the report doesn't see the object stored in the
session, but the JSP file executes successfuly.

2. I start with a report R1 that stores an object into session, then I
continue with a JSP file that tryies also to get that object from the
session. From the JSP file I go to a second repot R2 that tryies to
retrieve the session object stored by the first report. Results: the JSP
file fails to retrieve any object from the session (doesn't see any), but
the second report executes successfuly.

Are the session created by BIRT and servlet different? (I have provided in
previous messages the code for the servlet and BIRT reports). Can I do
anything so that the BIRT reports to see the session variables stored by
the servlet and the other way (the JSP to see the session variables stored
by the BIRT repor)?

Thank you,
Cristian

---------------------------
Servlet:

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.xxxxx.vo.DisplayVo;

public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

DisplayVo myDisplay = new DisplayVo();
myDisplay.setFirstString("first 111 from servlet");
HttpSession mySession = request.getSession();
mySession.setAttribute("myDis", myDisplay);
}
}
---------------------------------
Report R1:

var frame=new Packages.DisplayVo();

frame.setFirstString("aaaa");
this.valueExpr=frame.getFirstString();
reportContext.getHttpServletRequest().getSession().setAttrib ute( "myDis",
frame);

----------------------------------
Report R2:

var
frame2=reportContext.getHttpServletRequest().getSession().ge tAttribute(
'myDis');
this.valueExpr+="\n---frame2--- "+ frame2+" -----";
this.valueExpr+="\n---frame2-First element--- "+ frame2.getFirstString()+"
-----";

-----------------------------------
JSP File:
.....
Enumeration sessionNames= session.getAttributeNames();
if(sessionNames.hasMoreElements()){
out.println("********" + sessionNames.nextElement());
}
if(resultVo==null){
out.println("<H4>there is no DisplayVo instance in session!</H4>");
}else {
...
}
......

-------------------------------------
HELP!!!!!! Re: getting objects from the session [message #145529 is a reply to message #145405] Fri, 17 March 2006 13:22 Go to previous messageGo to next message
Eclipse UserFriend
I've tryed several scenarios:

1. I start with a servlet that stores an object into session, then I
continue with a report that tryies to get that object from the session.
From the report I go to a JSP file that tryies also to get that object
from the session. Results: the report doesn't see the object stored in the
session, but the JSP file executes successfuly.

2. I start with a report R1 that stores an object into session, then I
continue with a JSP file that tryies also to get that object from the
session. From the JSP file I go to a second repot R2 that tryies to
retrieve the session object stored by the first report. Results: the JSP
file fails to retrieve any object from the session (doesn't see any), but
the second report executes successfuly.

Are the session created by BIRT and servlet different? (I have provided in
previous messages the code for the servlet and BIRT reports). Can I do
anything so that the BIRT reports to see the session variables stored by
the servlet and the other way (the JSP to see the session variables stored
by the BIRT repor)?

Thank you,
Cristian

---------------------------
Servlet:

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.xxxxx.vo.DisplayVo;

public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

DisplayVo myDisplay = new DisplayVo();
myDisplay.setFirstString("first 111 from servlet");
HttpSession mySession = request.getSession();
mySession.setAttribute("myDis", myDisplay);
}
}
---------------------------------
Report R1:

var frame=new Packages.DisplayVo();

frame.setFirstString("aaaa");
this.valueExpr=frame.getFirstString();
reportContext.getHttpServletRequest().getSession().setAttrib ute( "myDis",
frame);

----------------------------------
Report R2:

var
frame2=reportContext.getHttpServletRequest().getSession().ge tAttribute(
'myDis');
this.valueExpr+="\n---frame2--- "+ frame2+" -----";
this.valueExpr+="\n---frame2-First element--- "+ frame2.getFirstString()+"
-----";

-----------------------------------
JSP File:
.....
Enumeration sessionNames= session.getAttributeNames();
if(sessionNames.hasMoreElements()){
out.println("********" + sessionNames.nextElement());
}
if(resultVo==null){
out.println("<H4>there is no DisplayVo instance in session!</H4>");
}else {
...
}
......

-------------------------------------
Re: getting objects from the session [message #145565 is a reply to message #145507] Fri, 17 March 2006 13:46 Go to previous messageGo to next message
Eclipse UserFriend
ok...i haven't got any new results. It shows me that the object is null,
even thou i refreshed the JSP page.
Re: getting objects from the session [message #145574 is a reply to message #145507] Fri, 17 March 2006 13:49 Go to previous messageGo to next message
Eclipse UserFriend
here is also my url from the report

http://localhost//viewer/run?__report=a.rptdesign&__form at=html&__svg=false&__locale=en_CA&__designer=tr ue&__masterpage=true&__overwrite=true
Re: HELP!!!!!! Re: getting objects from the session [message #145600 is a reply to message #145529] Fri, 17 March 2006 14:01 Go to previous messageGo to next message
Eclipse UserFriend
Cristian,

What app server do you have this deployed to?
If you are using Tomcat, just try what I put in my earlier post.

Jason

"Cristian" <ceol.gael@gmail.com> wrote in message
news:00508422ae8c80123c99b362efc43dc3$1@www.eclipse.org...
> I've tryed several scenarios:
>
> 1. I start with a servlet that stores an object into session, then I
> continue with a report that tryies to get that object from the session.
> From the report I go to a JSP file that tryies also to get that object
> from the session. Results: the report doesn't see the object stored in the
> session, but the JSP file executes successfuly.
>
> 2. I start with a report R1 that stores an object into session, then I
> continue with a JSP file that tryies also to get that object from the
> session. From the JSP file I go to a second repot R2 that tryies to
> retrieve the session object stored by the first report. Results: the JSP
> file fails to retrieve any object from the session (doesn't see any), but
> the second report executes successfuly.
>
> Are the session created by BIRT and servlet different? (I have provided in
> previous messages the code for the servlet and BIRT reports). Can I do
> anything so that the BIRT reports to see the session variables stored by
> the servlet and the other way (the JSP to see the session variables stored
> by the BIRT repor)?
>
> Thank you,
> Cristian
>
> ---------------------------
> Servlet:
>
> import java.io.IOException;
> import javax.servlet.ServletException;
> import javax.servlet.http.HttpServlet;
> import javax.servlet.http.HttpServletRequest;
> import javax.servlet.http.HttpServletResponse;
> import javax.servlet.http.HttpSession;
> import org.xxxxx.vo.DisplayVo;
>
> public class TestingServlet extends HttpServlet {
> public void doGet(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException {
>
> DisplayVo myDisplay = new DisplayVo();
> myDisplay.setFirstString("first 111 from servlet");
> HttpSession mySession = request.getSession();
> mySession.setAttribute("myDis", myDisplay);
> }
> }
> ---------------------------------
> Report R1:
>
> var frame=new Packages.DisplayVo();
>
> frame.setFirstString("aaaa");
> this.valueExpr=frame.getFirstString();
> reportContext.getHttpServletRequest().getSession().setAttrib ute( "myDis",
> frame);
>
> ----------------------------------
> Report R2:
>
> var
> frame2=reportContext.getHttpServletRequest().getSession().ge tAttribute(
> 'myDis');
> this.valueExpr+="\n---frame2--- "+ frame2+" -----";
> this.valueExpr+="\n---frame2-First element--- "+
> frame2.getFirstString()+" -----";
>
> -----------------------------------
> JSP File:
> ....
> Enumeration sessionNames= session.getAttributeNames();
> if(sessionNames.hasMoreElements()){
> out.println("********" + sessionNames.nextElement()); }
> if(resultVo==null){
> out.println("<H4>there is no DisplayVo instance in
> session!</H4>"); }else {
> ..
> }
> .....
>
> -------------------------------------
>
>
Re: getting objects from the session [message #145652 is a reply to message #145574] Fri, 17 March 2006 14:51 Go to previous messageGo to next message
Eclipse UserFriend
Are you doing this with your object or just a String? Just trying to
eliminate possible problems.
I am using BIRT 2.0.1 and I modified the index.jsp under the Birt viewer to
add it.


"Cristian" <ceol.gael@gmail.com> wrote in message
news:e0cfb2add7e2c86e3f2430bf7ef322ef$1@www.eclipse.org...
> here is also my url from the report
>
> http://localhost//viewer/run?__report=a.rptdesign&__form at=html&__svg=false&__locale=en_CA&__designer=tr ue&__masterpage=true&__overwrite=true
>
Finnaly works - Have a great weekend everybody [message #145739 is a reply to message #145077] Fri, 17 March 2006 17:02 Go to previous message
Eclipse UserFriend
Hi. I made it finnaly work. Thank you Jason, have a great Saint Patrick's
Day and a wonderful weekend. See you on Monday.

Cristian
Previous Topic:show display text of dynamic parameter on report
Next Topic:multi-report navigation
Goto Forum:
  


Current Time: Wed Jul 02 22:41:44 EDT 2025

Powered by FUDForum. Page generated in 0.06190 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top