On 7/5/07, Nhut Thai Le [EMAIL PROTECTED] wrote:
Hi,
I have configured my app as follow:
$CATALINA_HOME/conf/server.xml
Host name=localhost appBase=webapps
unpackWARs=true autoDeploy=true
xmlValidation=false
xmlNamespaceAware=false
Context path=/Core1
docBase=Core1
debug=5
reloadable=true
crossContext=true
Resource name=jdbc/TestDB
auth=Container
type=javax.sql.DataSource
maxActive=100
maxIdle=30
maxWait=1
username=iam
password=mypass
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost/mydb?autoReconnect=true/
/Context
/host
This tells the servlet container that the Core1 application has a connection
pool ready to be used
Then in the WEB-INF/web.xml i have:
listener
listener-class
com.core.listener.ResourceManagerListener
/listener-class
/listener
servlet
servlet-nameaction/servlet-name
servlet-class
org.apache.struts.action.ActionServlet
/servlet-class
init-param
param-nameconfig/param-name
param-value
/WEB-INF/struts-config.xml
/param-value
/init-param
init-param
param-namedebug/param-name
param-value2/param-value
/init-param
init-param
param-namedetail/param-name
param-value2/param-value
/init-param
load-on-startup2/load-on-startup
/servlet
servlet-mapping
servlet-nameaction/servlet-name
url-pattern*.do/url-pattern
/servlet-mapping
session-config
session-timeout
30
/session-timeout
/session-config
welcome-file-list
welcome-file
index.jsp
/welcome-file
/welcome-file-list
error-page
exception-typeException/exception-type
location/WEB-INF/error/error.jsp/location
/error-page
resource-ref
descriptionDB connection/description
res-ref-namejdbc/TestDB/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
The above tell the servlet container that the appication Core1 uses struts
framework which handle all requests ended with .do.
Finally, the struts-config.xml:
global-forwards
forward name=main path=/index.jsp/
forward name=login path=/authentication/login.jsp/
forward name=testS path=testStruts.jsp/
/global-forwards
action-mappings
!--
action path=/Welcome forward=/welcomeStruts.jsp/
--
action path=/testStruts
type=com.core.servlet.testStruts/
action path=/authentication
type=com.core.servlet.Authentication/
action path=/protected/financial
type=com.core.servlet.Financial
forward name=/protected/financialDisplay
path=/financial/financialDisplay.jsp/
forward name=/protected/financialInput
path=/financial/financialInput.jsp/
forward name=/protected/financialManager
path=/financial/financialManager.jsp/
forward name=/protected/financialSearch
path=/financial/financialSearch.jsp/
/action
action path=/protected/financialProcess
type=com.core.servlet.FinancialProcessor/
/action-mappings
Now, I have a testStruts class which extends Action class as follow:
public class testStruts extends Action
{
public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException,
UserInputException,
InternalException
{
System.out.println(print of this method is invoked);
return mapping.findForward(testS);
}
}
and the testStruts.jsp is just a normal jsp file in WEB-INF folder.
If its in the WEB-INF folder then it should be:
forward name=testS path=/WEB-INF/testStruts.jsp/
Niall
When I try to access testStruts.do (the controler) from my browser:
http://localhost:8084/Core1/testStruts.do
i though the testStruts.jsp will be displayed but there is nothing happen. I
got a blank page.
The testStruts class doesnt seem to be invoked anyway because nothing is print
out in the console.
Does anyone know why?
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]