The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Hi Lasse,

Thanks for quick reply. I don't use Maven but I fixed the problem. But now I have another problem, please check the stack trace

log4j:WARN No appenders could be found for logger (net.sf.jsptest.compiler.api.JspCompilerFactory).
log4j:WARN Please initialize the log4j system properly.
[Fatal Error] generated_html_32804.html.tidy.html:2:1: Premature end of file.

java.lang.RuntimeException: Premature end of file. (CsmilieOCUME~1NGUYEN~1LOCALS~1Tempgenerated_html_32804.html)
at net.sf.jsptest.HtmlTestCase.parseRenderedOutput(HtmlTestCase.java:86)
at net.sf.jsptest.HtmlTestCase.parseRenderedHtml(HtmlTestCase.java:75)
at net.sf.jsptest.HtmlTestCase.request(HtmlTestCase.java:60)
at net.sf.jsptest.JspTestCase.get(JspTestCase.java:94)
at com.tddinaction.j2ee.web.view.jsp.TestLoginPage.testFormFieldsArePresent(TestLoginPage.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: org.xml.sax.SAXParseException: Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:239)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:283)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:20smilie
at net.sf.jsptest.HtmlTestCase.parseRenderedOutput(HtmlTestCase.java:83)
... 27 more

Process finished with exit code -1

And please update JspTest on the web site, it's still version 0.9. Thanks
Thanks, Lasse. Now it's green smilie
I'm trying to test JSPs but when I run the test class, I have a RE

java.lang.RuntimeException: java.lang.RuntimeException: No JSP compiler implementation configured: (configuration file jsptest.properties not found from class path.


JspTest doesn't have any documentation. How can I configure JspTest? Thanks
Hi Lasse,

The problem is the JSP empty. I think JspTest should throw a more reasonable exception.

And now there is another problem, JspTest cannot find the "login" submit button.
[pre]
log4j:WARN No appenders could be found for logger (net.sf.jsptest.compiler.api.JspCompilerFactory).
log4j:WARN Please initialize the log4j system properly.

junit.framework.AssertionFailedError: No form submit button 'login' on page
at net.sf.jsptest.assertion.FormAssertion.shouldHaveSubmitButton(FormAssertion.java:53)
at com.tddinaction.j2ee.web.view.jsp.TestLoginPage.testFormFieldsArePresent(TestLoginPage.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)


Process finished with exit code -1
[/pre]
Here are my source code
[pre]
package com.tddinaction.j2ee.web.view.jsp;

import net.sf.jsptest.HtmlTestCase;

/**
* @author t800t8
*/
public abstract class MyJspTestCase extends HtmlTestCase {

@Override
protected String getWebRoot() {
return "src/com/tddinaction/j2ee/web/view/jsp";
}

}

package com.tddinaction.j2ee.web.view.jsp;

/**
* @author t800t8
*/
public class TestLoginPage extends MyJspTestCase {

public void testFormFieldsArePresent() throws Exception {
get("/login.jsp");
form().shouldHaveField("j_username");
form().shouldHaveField("j_password");
form().shouldHaveSubmitButton("login");
}

}

<%@ page language="Java" %>
<html>
<body>
<form>
<input type="text" name="j_username"/>
<input type="password" name="j_password"/>
<input type="submit" name="login"/>
</form>
</body>
</html>
[/pre]
In table 2.4, Ctrl + Numpad + correlative with Collapse all should be replaced by Ctrl + Numpad -
In table 2.3, Gtrl + G should be replaced by Ctrl + G
Before item 1.5, it has a paragraph:

use the Project tool window to create a package tree that ultimately includes com.acme.conversion.currency and com.acme.conversion.currency.client.

Maybe com.acme.conversion.currency should be replaced by com.acme.conversion.currency.service

It's from my ebook, not paperback.
In section 2.5.4 of ebook, it has a paragraph "The window.onload function that we saw in listing 2.9 is a callback function."

But here is listing 2.9

function getXMLHTTPRequest() {
var xRequest=null;

if (window.XMLHttpRequest) {
xRequest=new XMLHttpRequest();
}else if (typeof ActiveXObject != "undefined"){
xRequest=new ActiveXObject("Microsoft.XMLHTTP");
}

return xRequest;
}
These days I cannot download source code from Manning's site. Can anybody help me to get it?

Thanks
Thanks, now I can download it. Seems Manning fixed it smilie
I met the same problem and tried to use Hibernate 3.05 as jmerryman said, it works well.

And I saw that maybe the authors didn't care about this forum so they don't answer anything here.
I will glad to hear if Tapestry in Action will be upgraded to Tapestry 4.0. smilie
Answer by myself smilie

Tomcat have a functional which called "cache objects". Because that, method isValid() in my GreetingTagInfo always return false but Tomcat can't catch this exception. You can turn off cache objects function by modifying server.xml. Add attribute "reloadable" with value "true" in Context tag at Tomcat Root Context. This modifying works for developing only, not recommend for deploying.

Sorry for my English. It's terrible!
Nobody answer me? smilie
Sorry, I miss the tag library descriptor

<tag>
<name>greeting</name>
<tag-class>chapter6.GreetingTag</tag-class>
<tei-class>chapter6.GreetingTagInfo</tei-class>
<body-content>empty</body-content>
<description>Validate the value of an atrribute</description>

<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
I'm reading chapter 6 of this book and try to do some examples in this chapter. But I have a problem with validating attribute's value at translation time. See the code below:

/*
* GreetingTag.java
*/

package chapter6;

import java.io.IOException;

import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;

public class GreetingTag extends TagSupport {
private String name = null;

public int doStartTag() throws JspException {
try {
pageContext.getOut().println("Hello " + name);
}
catch (IOException ioe) {
throw new JspTagException("Error: IOException while writing to the user!");
}

return SKIP_BODY;
}

public void setName(String name) {
this.name = name;
}
}

++++++++++++++++++++++++++++++++++++++++++++++++++

/*
* GreetingTagInfo.java
*/

package chapter6;

import javax.servlet.jsp.tagext.TagData;
import javax.servlet.jsp.tagext.TagExtraInfo;

public class GreetingTagInfo extends TagExtraInfo {

public boolean isValid(TagData data) {
String name = data.getAttributeString("name");

//if (name.equals("bb")) {
return false;
//}

//return true;
}

}

++++++++++++++++++++++++++++++++++++++++++++++++++

<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://tlib.com/TagLibs" prefix="tlib" %>
<html>
<head><title>Validate the value of an attribute</title></head>
<body>

<myjpieces:greeting name="aa" />

</body>
</html>

+++++++++++++++++++++++++++++

The isValid() method in GreetingTagInfo always returns false in my example but my JSP page still run well, it doesn't show an exception or error. I'm using NetBeans 3.6 Beta with Tomcat 5.0.16 built-in. Pls help me. Thx a lot!