• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsf download pop up

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am pretty new to JSF. I thought I wanted to see how "real" web applications can be created and think I have by far underestimated the effort involved. Nevertheless, I still think it should be doable for me to learn, so I hope I don't bug you to much with dull questions. :(wait)::(wait):

My Starting point was reading some useful tutorials in the web and as next step I started reading the book "Beginning JSP, JSF and Tomcat" which - from my point of view - is quite a good book. However, now in chapter 8 I tried to install the "eshopf" into my tomcat and don't even get to see the index page. Instead I get a download requester (see attachment).



I would say there is nothing much complex involved, this is the web.xml:



And this is the index.jsp file:



Even when I integrate a welcome-file entry into the web.xml like this:



I still get this download thing.

Maybe someone has gotten this web application to work and knows what the problem is? Any ideas are appreciated as right now I don't have any idea what to do. I also considered including a MIME-Type but if that's relevant would be pure guessing and I don't know if it makes overall sense?

Thanks for your help,
Stephan
Bild1.jpg
[Thumbnail for Bild1.jpg]
Download Requester
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Englisch, bitte! We have many people who speak many languages and the only way we can accomodate them all is to use a common language. Aber wilkommen in der Ranch!

Whenever you get a file download when requesting a JSF page it means that the request wasn't routed through the JSF FacesServlet, which is the master Controller in JSF's Model/View/Controller architecture.

This can happen for one of 2 reasons:

1. You're using the wrong URL. For example "/welcome.xhtml" instead of "/welcome.jsf". Here you are requesting the resource file when you should be requesting the URL processor (FacesServlet).

2. You haven't mapped the URL to route to the FacesServlet. That's done in web.xml by
A. defining a servler mapping (for example, "*.jsf" as a URL pattern to "Faces Servlet" as the logical servlet ID.
B. Assigning the correct logical servlet ID to the Faces Servlet. z.Bs.:


The reason for the indirect setup of the welcome page is that the welcome page, like the form login page and the error pages that can be defined in web.xml isn't invoked via the normal URL handler, but is requested by the server itself, and the server may or may not route its internal requests through the entire URL processing chain (specifically, through the FacesServlet). So an ordinary HTML or JSP welcome page would forward to a JSF page request.

I think your real problem, however, is indicated in your "*.jspx" Faces default suffix. Normally that's set to a value of "*.xhtml". JSPs don't work as View templates under JSF Version 2, so while it's perfectly permissible to define a "*.jspx" named resource file in a JSF2 app, the actual contents of that file must conform to the xhtml (JSF View Template Language) format.

The biggest problem, alas, when attempting to use books to learn modern technology is that by the time it gets into book form, the information is often obsolete. JSF has especial problems in this regard.
 
Stephan Wöbbeking
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oha, sorry for the german title, I did not really realize it when I wrote it...

Thanks for the answer! So you say that these *.jspx files are not for JSF 2, so it doesn't make sense to them at all, they are outdated, is that correct? Eventually I - at least - got the Welcome message to show up by basically copying nearly everything from a web app test I had created successfully.

Nevertheless, the overall page is not displayed correctly. It's far from complex, I have tried to adjust it to the xhtml format and produced this:



However, the jsp:includes deliver the message that "Warning: This page calls for XML namespace http://java.sun.com/JSP/Page declared with prefix jsp but no taglibrary exists for that namespace." So I believe the definition at the top "xmlns:jsp="http://java.sun.com/JSP/Page" can't be correct, right? So how to write that? I have the impression that this has to be done completely different as I can't find much helping issues in the net. I must admit I haven't changed the files "TopMenu" and "LeftMenu" to xhtml yet as the warning makes me feel that my problem is well before that, correct?

Stephan
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "jsp" namespace isn't a tag library, I don't think, but rather hard-wired into the JSP compiler. Since JSF2 doesn't use JSPs, those tags cannot be processed.

And, incidentally, while JSTL tags do have backing libraries, and Oracle even has examples using JSTL in JSF, you shouldn't use JSTL with JSF. JSTL is basically foreign to how JSF works, it often doesn't work right, and even what does work is the result of a lot of work done because JSF1 was even worse with JSTL.

But not to worry. There are JSF native equivalents to just about all of these things. JSF2 uses facelets, which adds the "ui" tag set, and the ui:include tag does what the jsp:include tag did, plus it supports parameters, which I don't think the jsp include tag does (it has been a while, so I forget). In fact, using ui:include tags, you can create a tiled page template that's a lot easier to work with than the Apache "tiles" ever was.

Here's what one of my tiled layout templates looks like. I really should have defined a set of style classes for some of the more detailed elements, but real-world code is seldom optimal.
 
Stephan Wöbbeking
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks a lot for your new answer! That actually helped me a lot to understand another bit of this huge sized jungle right in front of me. ;) Apparently until now I was in the believe that JSF and JSTL are pretty much connected and belong to each other.

For me the problem is that I read some examples until they won't work. Because I don't have any much knowledge yet about it I don't know why so I find a different solution which looks only slightly different. But as you say it's completely different technology, right? So it seems I mix all that up... Your comments were great to help me get to see the start page at least. Next step is now to connect to a database - in some examples that's working fine but now the book I am refering to is using MySQL while I have been using JavaDB. So I will work on that and hope to get it to work.

Maybe you can quickly tell me, what the libraries "t - tomahawk" and "rich - richfaces" do?

Thanks a lot,
Stephan
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the biggest problems with the Internet is that it keeps old, outdated information visible long after it's obsolete, and in many cases, you see it ahead of more up-to-date stuff. One reason why I like my sources to carry dates on them. For years people were designing JSF using features that had been long supplanted by simpler, cleaner ones. So it's not just old books you have to worry about!

The JEE spec defines the JSF core, which includes the FacesServlet and the core JSF tagsets (h, f, ui, and so forth). However, JSF is extendable and quite a few third parties have done so, adding enhanced tags that support AJAX (which wasn't part of the core until JSF2), tooltips, pop-up dialogs, calendar controls, drop-down comboboxes, and much, much more. Tomahawk is one such extension, part of the MyFaces project at apache.org. RichFaces is an open-source extension set from Red Hat/JBoss (caution, RichFaces 3 and RichFaces 4 are about as upgradeable as VB6 and VB.Net). Then there's IceFaces, PrimeFaces, Oracle's got a set whose name escapes me but is mirrored in MyFaces Trindidad and so forth.

As far as JSF and databases go, JSF has zero database support. You code database logic in JSF apps the same way that you do in non-JSF apps. I use Hibernate JPA for most projects and the Spring Framework to inject my persistent data services classes into JSF backing beans (since the JSF core injection services only deal with JSF beans).

Beyond that, probably the most important thing to know is that software belongs in the backing beans (Model objects), the Controllers are all pre-written for you, and the View (xhtml) should be a template and avoid logical constructs. For example, don't code ui:repeat loops when what you're really trying to do is present a 2-dimensional table (that's what the h:dataTable is for).

Oh yeah. And avoid Request Scope. It's pretty useless in JSF.

 
Stephan Wöbbeking
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks again for the detailed description! I will continue trying to understand the use or non-use of the different framework but I like to use the out-of-the-box stuff without adding to much third-party extensions. The advantage is that it usually integrates much easier even in the occasion that you may have to rebuild the whole system at a later point in time.

With the backing beans, controllers and the persistence layer I think I am somehow aware off. That's actually where I need more practice to get into some routine, but I'm not at that point yet. I have been using the JPA already and I agree, it's a great thing to work with. In comparison to store objects by customized sql code "manually" in pre-configured tables in tremendous.

So I think the initial topic of this thread was solved, thanks to your replies.

Regards,
Stephan
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The extension tag libraries do not replace the core JSF, they add to it. The core tag libraries, for example, provide basic HTML form controls. But basic HTML doesn't include the popular drop-down comboBox control that desktop users are familiar with (and its benefits). So to get a comboBox in JSF, you have 2 options.

1. You can build one up by juxtaposing an h:inputText and a DIV or div-type element (1-cell panelGrid) and gluing them together with user-written JavaScript

2. You can include an extension tagset that provides a pre-defined comboBox tag.

I recommend the second option. You don't have to spend a lot of time coding and debugging and the actual page template source will be more abstract and less function.

There is considerable overlap between the various third-party tag libraries. The major ones are all feature-rich, so they all provide comboBoxes, enhanced, pageable tables, and other popular features. Normally you'd just pick one of them to be your shop standard. There are also special-purpose third-party tag libraries for stuff that's not as common.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic