Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » data-transfer to servlet
data-transfer to servlet [message #97097] Sun, 06 July 2008 14:36 Go to next message
Eclipse UserFriend
Originally posted by: rglorius.web.de

Hello,

I've startup an HTML-View in a external Browser. Im using a servlet to
generate the HTML-code.

IWorkbenchBrowserSupport browserSupport =
PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser iBrowser;
try {
iBrowser = browserSupport.createBrowser("Druckansicht");
URL url = new URL("http://127.0.0.1:2929/printTimeReports");
iBrowser.openURL(url);
} catch (MalformedURLException e) {
} catch (PartInitException e) {
}

<extension point="org.eclipse.equinox.http.registry.servlets">
<servlet alias="/printTimeReports"
class=" de.tudresden.inf.mmt.kp08.rap.ui.util.PrintTimeReportsServle t "
httpcontextId="org.eclipse.rap.httpcontext"
load-on-startup="false">
</servlet>
</extension>

This works great.


Now i want to implement a dynamic HTML-Output by data out of the backend.
The problem is that my new servlet gets a new session, so that I dont get
my session-specific data out of the main rap-project.

is there a way to submit data to the servlet? Ive just tried it this way:

main-application-code:
...
RWT.getSessionStore().setAttribute( "timeReportId", "testid_123");
...

servlet-code:
..
public void service(ServletRequest request, ServletResponse
response)throws ServletException, IOException {

System.out.println(request.getAttribute("timeReportId")); //thos didnt work

PrintWriter out = response.getWriter();
String html = "<html>...</html>"
out.print( html );

}..


but the request is still empty. maybe i must use the doGet-method with the
HttpServletRequest but i dont know how do openen the method?

is there a solution?

best regards,
Rob
Re: data-transfer to servlet [message #97130 is a reply to message #97097] Sun, 06 July 2008 18:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rsternberg.innoopract.com

Hi Rob,

Rob wrote:
> I've startup an HTML-View in a external Browser. Im using a servlet to
> generate the HTML-code.
> [...]

> Now i want to implement a dynamic HTML-Output by data out of the backend.
> The problem is that my new servlet gets a new session, so that I dont
> get my session-specific data out of the main rap-project.
>
> is there a way to submit data to the servlet? Ive just tried it this way:
>
> main-application-code:
> ..
> RWT.getSessionStore().setAttribute( "timeReportId",
> "testid_123");
> ..

this way, you put your attribute to into the RAP-specific session store.
To add it to the HTTP session directly, use

RWT.getRequest().getSession().setAttribute( ... );

> servlet-code:
> .
> public void service(ServletRequest request, ServletResponse
> response)throws ServletException, IOException {

you should rather overwrite the method

HttpServlet#doGet( HttpServletRequest req, HttpServletResponse resp)

as you need an HttpServletRequest instance to get access to the HttpSession.

> System.out.println(request.getAttribute("timeReportId")); //thos didnt work

You have to acquire the attribute from the HttpSession, not from the
request:

request.getSession().getAttribute( ... );

> [...]
> but the request is still empty. maybe i must use the doGet-method with
> the HttpServletRequest but i dont know how do openen the method?

Does your servlet extend HttpServlet?

Hope that helps,
Ralf
Re: data-transfer to servlet [message #97145 is a reply to message #97130] Mon, 07 July 2008 04:50 Go to previous message
Eclipse UserFriend
Originally posted by: rglorius.web.de

Hi Ralf,

thanks it works great!

I let the servlet extends HttpServlet. So the methods based on the
HttpServletRequest.

RWT.getRequest().getSession().setAttribute("test", "funktioniert");

request.getSession().getAttribute("test");

:-)

Many thanks, Rob
Previous Topic:Reopening the workbench after it has been closed
Next Topic:Display#getSyncThread wanted
Goto Forum:
  


Current Time: Wed Apr 30 14:46:40 EDT 2025

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

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

Back to the top