2

I am using Netbeans 7.1 with Glassfish 3.1.1, and JDK 6. I built a sample project from a Java EE 5 tutorial. Sample Projects Download, The project is the guessNumber project.

I open the project, assign the glassfish server to it, deploy it and run it. The result is this:

File Download Security Warning

What would cause this? Why doesn't Internet Explorer want to render this as an HTML page and offer to download the file instead? I saved the file. Here it is: guessNumber

I did not change any project settings. I also uninstalled and re-installed Netbeans, Glassfish, and JDK 6 and reinstalled just to be sure nothing got changed in those settings.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
YWE
  • 2,849
  • 28
  • 42

2 Answers2

2

IE does not support HTML files which are served with content type of application/xhtml+xml.

Change the following line in top of all JSPs

<%@ page contentType="application/xhtml+xml" %>

to

<%@ page contentType="text/html" %>

This was a mistake of the tutorial's authors (or, maybe, a purposeful stab towards IE users that they're using the wrong browser for the web; it works in real browsers like Chrome, Firefox, etc).


Unrelated to the concrete problem, don't use outdated JSF 1.x tutorials/books. Instead use JSF 2.x ones. With JSF 1.x and JSP you're basically working with dead technology. Glassfish 3.x supports JSF 2.x out the box already. JSF 2.x is part of Java EE 6. Concentrate on finding/reading JSF 2.x tutorials/books.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks. I should have figured that one out. And thanks for the other advice. I found the Java EE 6 tutorial. – YWE Jan 25 '12 at 20:24
  • You're welcome. At the bottom of our JSF tag wiki page you can find other links to JSF2 tutorials: http://stackoverflow.com/tags/jsf/info – BalusC Jan 25 '12 at 20:25
  • @BalusC using txt/html for XHTML is not standard-complaint... Internet Explorer >= 9 does however properly support it... text/xml might be a slightly better option, using text/html might result in the browser using the wrong parser. See http://www.w3.org/TR/2002/NOTE-xhtml-media-types-20020801/ (text/html is acceptable only if the page is also valid HTML) – Gert van den Berg Dec 18 '13 at 14:50
  • @Gert: uh uh please read http://stackoverflow.com/tags/xhtml/info for an eye opener. – BalusC Dec 18 '13 at 15:04
0

I got the same issue in IE , my issue fixed by just removing the pageencoding:

 pageEncoding="ISO-8859-1" .`
ashu
  • 1,339
  • 7
  • 27
  • 43