Embed a JSP inside a GWT widget?

181 views
Skip to first unread message

dablackgoku

unread,
May 23, 2007, 10:36:44 AM5/23/07
to Google Web Toolkit
Hi all,

I was wondering if it is possible to embed a JSP inside a GWT dialog
box. I know that you can setHTML() inside a GWT dialog box, but can
you specify a JSP file?

George Georgovassilis

unread,
May 23, 2007, 11:03:47 AM5/23/07
to Google Web Toolkit
How about an iframe? any component accepting HTML would be like:

component.setHTML("<iframe src='page.jsp'/>");

this more or less, with some styling (borders, scrollbars etc) should
do the trick

George Georgovassilis

unread,
May 23, 2007, 11:04:03 AM5/23/07
to Google Web Toolkit
How about an iframe? any component accepting HTML would be like:

component.setHTML("<iframe src='page.jsp'/>");

this more or less, with some styling (borders, scrollbars etc) should
do the trick

On May 23, 5:36 pm, dablackgoku <johnj...@gmail.com> wrote:

Luc Claes

unread,
May 23, 2007, 11:07:21 AM5/23/07
to Google Web Toolkit
Perhaps you could embed a 'Frame' widget in your dialog box and use
setURL() to specify your jsp file.

Luc

Luc Claes

unread,
May 23, 2007, 11:07:40 AM5/23/07
to Google Web Toolkit
Perhaps you could embed a 'Frame' widget in your dialog box and use
setURL() to specify your jsp file.

Luc

On May 23, 4:36 pm, dablackgoku <johnj...@gmail.com> wrote:

George Georgovassilis

unread,
May 23, 2007, 11:17:23 AM5/23/07
to Google Web Toolkit
Sorry for double posting, groups is being stubborn again

Ryan Dewsbury

unread,
May 23, 2007, 1:02:39 PM5/23/07
to Google Web Toolkit
Yeah, an iframe will do the trick. The one restriction you get from
this, which may not be an issue, is that your page is confined to the
defined space of the iframe, if the jsp's generated HTML is bigger
you'll get scroll bars. The alternative, which may be a bit more work,
is to asynchronously GET the jsp page from the server using GWT's
HTTPRequest class, then use the setHTML method with the result.
Perhaps delay loading the dialog until the result is returned, or
display a loading indication, or preload the JSP result when your app
starts.

One thing to note, which may be obvious, is that you can't actually
embed a JSP file in a GWT app. JSP and GWT being two different HTML
rendering technologies, JSP is rendered on the server and GWT is
rendered in the browser. When you embed JSP in a GWT dialog you are
actually embedding HTML that was generated from the server. This
means you need to make an HTTP GET request to the server for the JSP
page so that it is rendered and returns HTML. The two ways to make
this request are through an iframe or an HTTPrequest.

Brill

unread,
May 23, 2007, 4:22:47 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:23:16 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:23:34 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:24:06 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:24:39 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:32:43 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:32:48 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:32:52 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:32:58 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:33:02 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:33:05 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:33:10 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

Brill

unread,
May 23, 2007, 4:33:13 PM5/23/07
to Google Web Toolkit
JSP is actually compiled by the servlet engine into a servlet
instance.
So the short answer is no, GWT can't compile your JSP.

As has been suggested though, you can request it as a "static"
resource from the server. The method here has been and iframe, but
there is also a way to request static content programatically using an
HttpRequest.
There is an implementation out there already for doing just that, but
I'm not sure which extension module I noticed it in.

- Brill Pappin

On May 23, 10:36 am, dablackgoku <johnj...@gmail.com> wrote:

dablackgoku

unread,
May 24, 2007, 10:54:34 AM5/24/07
to Google Web Toolkit
Thanks for all the replies guys. I was able to embed my page into the
dialog box. It wasnt as straight forward was I thought.

My JSP pages are tiled and contains JSF tags, thus I cannot strictly
iframe the JSP page. Instead, I had to iframe the whole XXX.faces url
so the JspTilesViewHandlerImpl render the JSP out correctly. Note
that the full URL address is required, otherwise it will try to pull
out the XXX.face file which doesnt exist. Here is my code..

private DockPanel rootPanel = new DockPanel();
HTML html = new HTML("<iframe src='" + GWT.getModuleBaseURL() +
"XXX.faces' height='100%' width='100%' scrolling='auto' frameborder=0 /
>");
rootPanel.add(html, DockPanel.NORTH);
rootPanel.setCellHeight(html, "100%");
this.add(rootPanel);
rootPanel.setSize("100%", "100%");


Creating a Frame object works as well, you will need to specify the
style.

private DockPanel rootPanel = new DockPanel();
Frame frame = new Frame();
frame.setUrl(GWT.getModuleBaseURL() + "XXX.faces");
frame.setStyleName(CONSTANT.STYLE_IFRAME_DIALOG);
rootPanel.add(frame, DockPanel.NORTH);
rootPanel.setCellHeight(html, "100%");
this.add(rootPanel);
rootPanel.setSize("100%", "100%");

John

> > you specify a JSP file?- Hide quoted text -
>
> - Show quoted text -

Brill

unread,
May 24, 2007, 12:22:29 PM5/24/07
to Google Web Toolkit
Sorry for all the identical posts... the darn forum software kept
telling me that the post failed!
... obviously it didn't...

Arthur Lance

unread,
May 24, 2007, 2:05:35 PM5/24/07
to Google-We...@googlegroups.com
private DockPanel rootPanel = new DockPanel();
HTML html = new HTML("<iframe src='" + GWT.getModuleBaseURL()  +
"XXX.faces' height='100%' width='100%' scrolling='auto' frameborder=0 /
>");
rootPanel.add(html, DockPanel.NORTH);
rootPanel.setCellHeight(html, "100%");
this.add(rootPanel);
rootPanel.setSize("100%", "100%");


Creating a Frame object works as well, you will need to specify the
style.

private DockPanel rootPanel = new DockPanel();
Frame frame = new Frame();
frame.setUrl(GWT.getModuleBaseURL() + "XXX.faces");
frame.setStyleName(CONSTANT.STYLE_IFRAME_DIALOG);
rootPanel.add (frame, DockPanel.NORTH);

rootPanel.setCellHeight(html, "100%");
this.add(rootPanel);
rootPanel.setSize("100%", "100%");

Try testing the results in firefox.. IT's DOM actually attempts to download ur embedded jsp file. Another disadvantage of using the iframe is that your source code is exposed once again as opposed to creating an async connection to get the file from the server.
 
ArthurLance
Reply all
Reply to author
Forward
0 new messages