Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Running a JSP or Servelet from RAP(Running a JSP or Servelet from RAP)
Running a JSP or Servelet from RAP [message #479014] Fri, 07 August 2009 22:53 Go to next message
Eclipse UserFriend
Hi,

I'm writing a custom widget that displays an image.

The HTML tags are generated on the server, along with an image that is stored in the Session variable. My intention was to pass the relative path to the image to the img src tag in html and use it to draw the image on the client, or have something like img src="GetImage.jsp?MyImage.png" which will call a JSP that read the image binary from the session and pass it back to the client.

I was able to store my image in a temporary file in a temp directory, outside of the Jetty root. However, I don't know how to retrieve Jetty's relative path to assign it to the img src tag in html. Also, I doubt Jetty will allow reading files from directories oustide of its root, for security reasons.

If I keep my image in a session, how can I send it to the custom widget JavaScript to render in the browser?

I would appreciate any hints or informaiton on this topic.
Re: Running a JSP or Servelet from RAP [message #479032 is a reply to message #479014] Sat, 08 August 2009 07:41 Go to previous messageGo to next message
Eclipse UserFriend
Hi Emile,

take a look at this FAQ entry:
http://wiki.eclipse.org/RAP/FAQ#How_to_provide_download_link .3F

It's the same procedure but without the Content-Disposition header.

Greets
Ben

Emile wrote:
> Hi,
>
> I'm writing a custom widget that displays an image.
> The HTML tags are generated on the server, along with an image that is
> stored in the Session variable. My intention was to pass the relative
> path to the image to the img src tag in html and use it to draw the
> image on the client, or have something like img
> src="GetImage.jsp?MyImage.png" which will call a JSP that read the image
> binary from the session and pass it back to the client.
>
> I was able to store my image in a temporary file in a temp directory,
> outside of the Jetty root. However, I don't know how to retrieve Jetty's
> relative path to assign it to the img src tag in html. Also, I doubt
> Jetty will allow reading files from directories oustide of its root, for
> security reasons.
>
> If I keep my image in a session, how can I send it to the custom widget
> JavaScript to render in the browser?
>
> I would appreciate any hints or informaiton on this topic.


--
Benjamin Muskalla | EclipseSource Karlsruhe
http://www.eclipsesource.com | http://twitter.com/eclipsesource
Re: Running a JSP or Servelet from RAP [message #479085 is a reply to message #479032] Sat, 08 August 2009 19:28 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ben,

Many thanks for the link.

The solution works like a charm.

There is so much to RAP and from my brief experimentation with it, I can say it rocks.


Cheers,


Emile
Re: Running a JSP or Servelet from RAP [message #479111 is a reply to message #479085] Sun, 09 August 2009 06:32 Go to previous messageGo to next message
Eclipse UserFriend
>
> There is so much to RAP and from my brief experimentation with it, I can
> say it rocks.

Thanks. We're glad to hear that and are working hard to make everyone
happy :)
Re: Running a JSP or Servelet from RAP [message #479236 is a reply to message #479014] Mon, 10 August 2009 08:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ben,

I have one more question related to this widget.

In my widget, I'm passing the img tag as html and setting it in my qooxdoo javascript as such:

document.getElementById(this._id).innerHTML


My innerHTML text output is similar to the following:

<img src=\"/rap?custom_service_handler=GetChartHandler&img=chart90321cc2-62f4-4cb8-9bfe-99dbb82ba942.png&id=rvvp5qlkd41b_5\" usemap=\"#map90321cc2-62f4-4cb8-9bfe-99dbb82ba942' border=\"0\">

<map name=\"map90321cc2-62f4-4cb8-9bfe-99dbb82ba942\">

<area shape=\"poly\" coords=\"242,135,231,164,220,174,159,135\" My sample map href=\"javascript:;?sector=0&label=NSW&value=1&percent=11.76\">

<area shape=\"rect\" coords=\"241,155,282,182\" My sample map href=\"javascript:;?sector=0&label=VIC&value=1&percent=11.76\">

</map>


This displays the image, but I can't click on the defined map areas to trigger action or a function on the RAP server side.

How can I have the href links (javascript in my case) call the RAP widget on the server passing the sector, label and value parameters found in the href links inside the map tag?

Cheers,

Emile
Re: Running a JSP or Servelet from RAP [message #479430 is a reply to message #479014] Mon, 10 August 2009 22:01 Go to previous message
Eclipse UserFriend
I have answered my own question, but I'm not sure if this way of doing it is right. I'd like to hear your opinion.

In my js file, I have a load function that gets called when I set the innerHTML tags for my widget.

The Java control appends the html tags for the image and the map areas and sets the mapHTML variable.
The LCA class then ties this back in the RAP widget lifecycle to my js load function.
The load function then replaces all occurences of the string #w# into a call to the client side widget. The way it does it is by finding the widget by name using the WidgetManager class.

load : function() {
			qx.ui.core.Widget.flushGlobalQueues();
			document.getElementById(this._id).innerHTML = 
				this.getMapHTML().replace(/#w#/g, "org.eclipse.swt.WidgetManager.getInstance().findWidgetById('" 
						+ this._id + "')");
		}



Here's the output of my HTML:

javascript:org.eclipse.swt.WidgetManager.getInstance().findWidgetById('w3').clickArea('sector=0&label=VIC&value=5')
Previous Topic:URGENT: JavaScript error after update
Next Topic:error running RAp application under equinoz 3.5
Goto Forum:
  


Current Time: Thu Jul 03 05:28:23 EDT 2025

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

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

Back to the top