jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Testing Meta Tags
Date Sun, 04 Aug 2002 21:03:18 GMT
Hum no idea then ...

What does Cactus WebResponse.getConnection().getContentType() returns ?
(I don't remember the exact API)

-Vincent

> -----Original Message-----
> From: Hugo A. Garcia [mailto:hgarcia@oogo.net]
> Sent: 08 July 2002 18:47
> To: Cactus Users List
> Subject: RE: Testing Meta Tags
> 
> 
> I did have the contentType set... that is what bums me.
> 
> -H
> 
> 
> Quoting Vincent Massol <vmassol@octo.com>:
> 
> > Hi Hugo,
> >
> > Your servlet needs to define what mime type it returns with :
> >
> >         response.setContentType("text/html");
> >
> > -Vincent
> 
> Here is the code:
> 
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> import java.io.*;
> import java.util.*;
> 
> /**
>  * @author Hugo A. Garcia
>  * Jul 5, 2002
>  **/
> public class Simple extends HttpServlet {
> 
> 	ServletContext context;
> 
> 	public void init(ServletConfig config) throws
> ServletException {
> 		super.init(config);
> 		context = getServletConfig().getServletContext();
> 	}
> 
> 	/** Handles the HTTP <code>GET</code> method.
> 	* @param request servlet request
> 	* @param response servlet response
> 	*/
> 	protected void doGet(
> 		HttpServletRequest request,
> 		HttpServletResponse response)
> 		throws ServletException, java.io.IOException {
> 
> 		processRequest(request, response);
> 	}
> 
> 	/** Handles the HTTP <code>POST</code> method.
> 	* @param request servlet request
> 	* @param response servlet response
> 	*/
> 	protected void doPost(
> 		HttpServletRequest request,
> 		HttpServletResponse response)
> 		throws ServletException, java.io.IOException {
> 
> 		processRequest(request, response);
> 	}
> 
> 	protected void processRequest(
> 		HttpServletRequest request,
> 		HttpServletResponse response)
> 		throws IOException, ServletException {
> 
> 		response.setContentType("text/html");
> 		java.io.PrintWriter out = response.getWriter();
> 
> 		//out.println("<?xml version=\"1.0\" encoding=\"iso-
> 8859-1\"?>");
> 		//out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD
> XHTML 1.0 Strict//EN\"");
> 		//out.println
> ("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\" >");
> 		//out.println("<html
> xmlns=\"http://www.w3.org/1999/xhtml\">");
> 		out.println("<head>");
> 		out.println("<meta http-equiv=\"Content-Type\"
> content=\"text/html\" />");
> 		out.println("<title>No title</title>");
> 		out.println("<meta name=\"command\"
> content=\"Browse\" />");
> 		out.println("</head>");
> 		out.print("<body>");
> 		out.println("<h1>Simple</h1>");
> 		out.print("</body>");
> 		out.println("</html>");
> 		out.flush();
> 		out.close();
> 	}
> 
> 	public void destroy() {
> 	}
> 
> }
> 
> 
> 
> 
> 
> 
> 
> 
> > > -----Original Message-----
> > > From: Hugo A. Garcia [mailto:hgarcia@oogo.net]
> > > Sent: 08 July 2002 14:26
> > > To: cactus-user@jakarta.apache.org
> > > Subject: Testing Meta Tags
> > >
> > >
> > > Hi
> > >
> > > I am using cactus and I am trying to test a meta tag BUT I
> > continously
> > > get a false for isHtml() or an execpection telling me that the
> > content
> > > is not text/html but text/plain.
> > >
> > > How do i test meta tags?
> > >
> > > here is the code...
> > >
> > > import javax.servlet.*;
> > > import javax.servlet.http.*;
> > > import org.apache.cactus.*;
> > > import junit.framework.*;
> > >
> > > /**
> > >  * @author Hugo A. Garcia
> > >  * Jul 8, 2002
> > >  **/
> > > public class SimpleTest extends ServletTestCase {
> > >
> > >         /**
> > >          * Constructor for SimpleTest.
> > >          * @param arg0
> > >          */
> > >         public SimpleTest(String arg0) {
> > >                 super(arg0);
> > >         }
> > >
> > >         public void testSendParams() {
> > >                 Browse servlet = (Browse)
> > WikiStrategy.create("Browse");
> > >
> > >         }
> > >
> > >         public void
> > endSendParams(com.meterware.httpunit.WebResponse
> > > aWebResponse) {
> > >
> > >                 assertTrue(aWebResponse.isHTML());
> > >
> > >                 /*
> > >                 try {
> > >
> > >                         String[] commandAttribute = null;
> > >                         commandAttribute =
> > > aWebResponse.getMetaTagContent("name", "command");
> > >                         assertEquals("Browse",
> > commandAttribute[0]);
> > >                 } catch (SAXException e) {
> > >                         e.printStackTrace();
> > >                 }
> > >                 */
> > >         }
> > > }
> > >
> > >
> > > -------------
> > >
> > > import javax.servlet.*;
> > > import javax.servlet.http.*;
> > > import org.apache.cactus.*;
> > > import junit.framework.*;
> > >
> > > /**
> > >  * @author Hugo A. Garcia
> > >  * Jul 8, 2002
> > >  **/
> > > public class SimpleTest extends ServletTestCase {
> > >
> > >         /**
> > >          * Constructor for SimpleTest.
> > >          * @param arg0
> > >          */
> > >         public SimpleTest(String arg0) {
> > >                 super(arg0);
> > >         }
> > >
> > >         public void testSendParams() {
> > >                 Simple servlet = new Simple();
> > >         }
> > >
> > >         public void
> > endSendParams(com.meterware.httpunit.WebResponse
> > > aWebResponse) {
> > >
> > >                 assertTrue(aWebResponse.isHTML());
> > >
> > >                 /*
> > >                 try {
> > >
> > >                         String[] commandAttribute = null;
> > >                         commandAttribute =
> > > aWebResponse.getMetaTagContent("name", "command");
> > >                         assertEquals("Browse",
> > commandAttribute[0]);
> > >                 } catch (SAXException e) {
> > >                         e.printStackTrace();
> > >                 }
> > >                 */
> > >         }
> > > }
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:   <mailto:cactus-user-
> > > unsubscribe@jakarta.apache.org>
> > > For additional commands, e-mail: <mailto:cactus-user-
> > > help@jakarta.apache.org>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:cactus-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:cactus-user-help@jakarta.apache.org>
> >
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:cactus-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:cactus-user-
> help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message