data-transfer to servlet [message #97097] |
Sun, 06 July 2008 14:36  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.07892 seconds