File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jsp page appears in xml tree format. how can i fix this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp page appears in xml tree format. how can i fix this?" Watch "jsp page appears in xml tree format. how can i fix this?" New topic
Author

jsp page appears in xml tree format. how can i fix this?

Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
hello, im trying to run a simple example using JSP document using xml syntax but cannot display the content output as jsp. the page loads in xml tree format in the browser.

how do i display the content as jsp/html?

here is my html


it goes to a /searchcontroller.jsp file with the following code


public String getView() {
return "/emptysearch.jsp";
}



which forwards to this /emptysearch.jsp page



now when i enter the first html form it takes me to a page with xml tree for the above jsp instead of displaying it in jsp or html format. I have added the jsp:directive.page contentType="text/html; charset=ISO-8859-1" but it still doesnt display the page as a jsp..

please help
thanks


Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

Joe Marchi wrote:I have added the jsp:directive.page contentType="text/html; charset=ISO-8859-1".....

Can you show us that code?


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
the code for <jsp:directive.page contentType="text/html; charset=ISO-8859-1"/> is displayed in the jsp pages itself.

the web.xml simply redirects to a jsp page



thanks
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

Joe Marchi wrote:the code for <jsp:directive.page contentType="text/html; charset=ISO-8859-1"/> is displayed in the jsp pages above.

Sorry I didn't see that before.

I guess the problem is with the charset. I suggest you to replace ISO-8859-1 with UTF-8.
Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
Hi Devaka, I tried replacing it by UTF-8 but still get the same xml tree in the browser i have tried IE and Firefox also to no avail.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

Strange!
What's the server/container are you using?
Can you show us the exact output which is produced?

[Edited: to fix typo]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yeah, are you sure your container supports JSP XML (or whatever that's called)?
Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
I am using weblogic server 10.3. the page output is this:

---------------------------------------------------
This XML file does not appear to have any style information associated with it. The document tree is shown below.

−-----------------------------------------------
<html>

<head>
<title>Using Search Bean: no items found</title>
</head>

<body>
<h1>No items found</h1>

<form action="search">

<p>
Your search for "drege" returned no items. Try another search to find a match.
</p>

<p>
Search keywords:
<input type="text" size="30" name="keywords" value="drege"/>
</p>
<input value="Submit"/>
</form>
</body>
</html>


my web.xml looks like this:



my weblogic.xml looks like this



this example is out of the book j2ee applications and bea weblogic server second edition which would have probably worked for weblogic 8.1 but i am using weblogic 10.3.

not sure how to fix this!!!
Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
the weblogic container should display jsp documents for xml as its part of the jsp specification but something is not being flagged here or is not compatible ive tried to change the jsp:root version to 1.2 but i still get the same xml tree instead.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

What happens if you name the JSP file with a .jspx extension?
Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
it produces the same result could i send you the code perhaps to review?
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

Joe Marchi wrote:could i send you the code perhaps to review?

Please UseTheForumNotEmail

I've no clue of how this is happening. But I'm still thinking that it has something to do with the content type.
Just try this out:

Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
my bad this was actually resolved using the context type directive that i had used ealier.

i feel stupid for mentioning what mistake i made so i will keep it to myself
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Joe Marchi wrote:i feel stupid for mentioning what mistake i made so i will keep it to myself

That's too bad, because now nobody else will know at least one thing to avoid.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

David Newton wrote:That's too bad, because now nobody else will know at least one thing to avoid.

+1
Joe Marchi
Greenhorn

Joined: Apr 25, 2010
Posts: 11
out of respect to you, i actually created a second project with another context root and was making changes to it but displaying the output from the first context root therefore not really seeing the changes. Hey, caffeine can only do soo much at 3:00 am in the morning.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Hopefully people will avoid changing one project and running another ;)

(I think we've all done that at one point or another--opened a file from another project by accident, edited it, then been baffled why the change "doesn't work". I've been doing it for decades :)
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3019
    
  35

David Newton wrote:we've all done that at one point or another

+1 again for that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp page appears in xml tree format. how can i fix this?
 
Similar Threads
include directive doesn't work
Jsp Pagination
JSF Components does not appear on the browser
dont want a JSP page appear as XML
wanted to create own tag in struts using NetBeans and use it in .jspx file