Forum Moderators: open

Message Too Old, No Replies

XHTML 1.0 validation and Java Servlets

I am trying to figure out how to properly use Java Servlets with XHTML 1.0

         

rexrhino

1:14 pm on Jun 18, 2004 (gmt 0)

10+ Year Member



I am currently tasked to converting a lot of jumbled HTML documents into strict validated XHTML 1.0 code. The trouble I am having is how to get Java Servlets on the page to be acceptable to the XHTML 1.0 form.

For example, here is how servlets are inserted now:

<servlet code="navigation">
<param name="type" value="header" />
<param name="language_code" value="en" />
<param name="section" value="example_1" />
</servlet>

XHTML 1.0 doesn't recognize the servlet tag. Is there another way to get it to work?

tedster

10:16 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been trying to research this for you - but I'm not a java user and I'm handicapped.

As far as I know, <servlet> has never been an html element - I believe it's an xml tag. It's not that it has been deprecated, it never was there to begin with. I know that's not much, but maybe it can help give your search a new direction.

BlobFisk

10:42 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A servlet is a piece of server side code that serves up HTML to the client - it should never leak through to the browser.

Your code doesn't look like any servlet code I've seen. With Java servlets I'd expect to see something like:


import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

res.setContentType("text/html");
PrintWriter out = res.getWriter();

out.println("<HTML>");
out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>Hello World</H1>");
out.println("</BODY></HTML>");
}
}

Which is the ubiqitous Hello World!

As tedster said, <Servlet> is not an XHTML tag - what you posted looks more like an Applet code or some XML as tedster also suggested...

Where did this code come from? Perhaps it's an artifact from the server side?

[edited by: BlobFisk at 11:35 pm (utc) on June 18, 2004]

iamlost

11:02 pm on Jun 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to use <object> to embed such things in HTML.

<object codetype="application/java" classid="http://www.yoursite/yourdirectory/navigation.class">
<param name="type" value="header" valuetype="data" />
<param name="language_code" value="en" valuetype="data" />
<param name="section" value="example_1" valuetype="data" />
</object>

You will have to modify it but something that should work.