• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Directive Visible on Webpage

 
Erik Zimmerman
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first post here...

I have a JSP page with a directive at the top of the page. It looks like this:

<%@ page language="java" import="java.sql.*"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"
trimDirectiveWhitespaces="false"%>

(Note I have also tried putting the above code all on one line)

The shows code shows as plain text when the JSP page is deployed to the server. It is hidden as expected on my development machine.

What could cause this? A configuration file somewhere?

Using the website "validator.w3.org" I get the following error returned about the above line when run from the server:

1. Error Line 5, Column 1: character data is not allowed here

<%@ page language="java" import="java.sql.*"

You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
* putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
* forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
* using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.

So... this is telling me that the leading character "<" is not valid???

The really strange part of it is that when I use the code clean up feature in the site, it returns the same value for the "invalid" line.

What could be wrong here?

Erik
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the server may not be processing the page as JSP and is simply serving it as plain text. Are other JSP mechanisms on the page evaluated?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. The wc3 validator is for validating HTML not JSP. Of course it's going to complain.
 
Erik Zimmerman
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Sounds like the server may not be processing the page as JSP and is simply serving it as plain text. Are other JSP mechanisms on the page evaluated?


Thanks for the reply. It is quite possible that the server is not processing the page as JSP. There are a few scriptlets with calls in to the database to display some data. Those are not working. What troubles me the most is that I can make a simple page of two lines with something like "Hello" and "GoodBye" and it pages fine. As soon as I add the directive at the top of the page, it fails. In Google Chrome I see all of the html as plain text. In IE the html formats the text correctly but the SQL statements don't render correctly on the page. The SQL is probably not executing (my guess).

Are there any good tools to validate the JSP like the html tool that I was using? What do you suggest?

Please ask more questions if you need. I will provide as much information as possible.

Thanks again,

Erik
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First to back way, way up, there should be no scriptlets on your JSP pages. That's technology that been discredited for almost ten years now. But that's not your current problem. But very soon, you are going to need to update your JSP knowledge.

Now onto the current issue: your description of what is going on is disorganized and not well thought out.

When a page gets to the browser, does a View Source show the original JSP page or not? Simple as that.

Is the setup on the server the same as on your development machine? (same version of servlet container and so on)?
 
Erik Zimmerman
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:First to back way, way up, there should be no scriptlets on your JSP pages. That's technology that been discredited for almost ten years now. But that's not your current problem. But very soon, you are going to need to update your JSP knowledge.

Now onto the current issue: your description of what is going on is disorganized and not well thought out.

When a page gets to the browser, does a View Source show the original JSP page or not? Simple as that.

Is the setup on the server the same as on your development machine? (same version of servlet container and so on)?


Admittedly, I am just starting out in Java, JSP and the like. Much of what I am doing is based on samples provided by a friend who hasn't worked with JSP recently. That said, this is my problem, and I just want get this to work and make the customer happy.

I'll try to describe my troubles clearly. Thank you for your patience so far.

Yes, the "View Source" looks the same as the original source. In fact it shows the scriptlets.

No, unfortunately, my development environment is far different from the server. Mine is Windows XP Pro and my IDE is Eclipse v 3.2. The server is running Fedora Red Hat. I thought that Java was pretty much platform independent. Guess I was wrong there.

Thanks again,

Erik
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Erik Zimmerman wrote:Yes, the "View Source" looks the same as the original source. In fact it shows the scriptlets.

That clearly shows that the pages are being served directly without being interpreted as JSPs.

No, unfortunately, my development environment is far different from the server. Mine is Windows XP Pro and my IDE is Eclipse v 3.2. The server is running Fedora Red Hat. I thought that Java was pretty much platform independent. Guess I was wrong there.

What does this have to do with Java being platform independent? None of what you list here is pertinent. What servlet containers are being used? Are you sure that the remote server is even running a servlet container?
 
Erik Zimmerman
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Erik Zimmerman wrote:Yes, the "View Source" looks the same as the original source. In fact it shows the scriptlets.

That clearly shows that the pages are being served directly without being interpreted as JSPs.

No, unfortunately, my development environment is far different from the server. Mine is Windows XP Pro and my IDE is Eclipse v 3.2. The server is running Fedora Red Hat. I thought that Java was pretty much platform independent. Guess I was wrong there.

What does this have to do with Java being platform independent? None of what you list here is pertinent. What servlet containers are being used? Are you sure that the remote server is even running a servlet container?


Do think that the fact that the pages are being interpreted as JSPs is something that I can pin on the hosting company, because as of now, they are telling me that there are scripting errors?

Thanks again,

Erik
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64175
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scripting errors would cause errors, not the page to appear as its source. Something is fishy...
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How is your server configured? What type of servlet container are you using? It sounds like you may be deploying the JSP file to a simple web server instead of a servlet container.
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure JSP is supported by your hosting provider?
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic