This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not able to run jsp's using struts

 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I am learning how to use struts and I am not able to connect 2 jsps using struts, although both are working fine if I use them separately. I am using tomcat 5.0.28 and struts 1.3.8.
codes are as follows:

index.jsp
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html"%>
<HTML>
<HEAD>
<TITLE>My Human Resources Portal</TITLE>
</HEAD>
<BODY>
<font size="+1"> My Human Resources Portal</font><br>
<hr width="100%" noshade="true">
Add an employee<br>
<html:link forward="search"> search for employees</html:link><br>
</BODY>
</HTML>

search.jsp
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html"%>
<html>
<head><title>My Human resources portal - Employee search</title></head>
<body>
My human resources portal - employee search
<hr>
</body>
</html>

web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/tlds/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
</taglib>

</web-app>
 
Tamas Jano
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi and welcome to the ranch!

Where is your struts-config file?
You have to register an action class in the web.xml and a configuration file with the action mappings.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you expand on "not able to connect 2 jsps using struts"? What error do you see in the browser?

- Brent
 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">

<struts-config>
<global-forwards>
<forward name="search" path="/search.jsp"/>
</global-forwards>
</struts-config>

this is my struts-config file

I am not sure, but I think I need to add reference of struts-config.xml in web.xml. If you guys think I should be then how can I add without using servlets.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have entries in your web.xml that look something like this:



- Brent
 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Brent,
your code seems to be ok but I haven't started using servlet in my code yet. Only wants to join 2 jsps using struts. Is that possible.
 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Brent,
Thanks for your help. I have got it my mistake. It's all your help to got me over the problem. Thanks once again.
regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic