This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
To narrow down the search when I hit the URL http://localhost:8080/struts/dispatchAction.jsp it is showing the page properly and links are also working. So i think the .jsp page is working fine. What I think is that there is some issue in name OR parameter attribute in the <action> tag.
1) When you hit the link, what is the url you see on the browser ? And at the same time, you can use FireBug to see if any other request parameters are sent.
2) You can change your action class from DispatchAction to normal action (org.apache.struts.action.Action), and print the request parameter map, and see what request parameters are coming in the request.
2) I changed the action class from DispatchAction to Action and printed the requestParameter Map. Following is the code snippet.
Following is the output :
14:43:45,193 INFO [ComposableRequestProcessor] Initializing composable request processor for module prefix ''
14:43:45,209 INFO [CreateAction] Initialize action of type: com.example.dispatchaction.DispatchActionExample
14:43:45,209 INFO [STDOUT] In execute method ::
14:43:45,209 INFO [STDOUT] null
14:43:45,209 INFO [STDOUT] Query String ::: null
But my thinking is that in the first hit it has to show the jsp (dispatchAction.jsp) which has the links so why would there be some request parameter. First it ought to show the jsp then only when I click on the link then it would send the request parameter.
Siddharth Bhargava wrote:
I am getting the following exception everytime.
Sorry I have to go back to your first post, as there is some confusion. When are you seeing this problem exactly ?
Joined: Feb 23, 2007
I get this exception when I hit the URL : http://localhost:8080/struts. The flow is like this : On hitting this URL it would look for index.jsp. In index.jsp I have written the following code :
so it gets redirected to the dispatchAction in strtus-config.xml where we have the following :
Then it goes to the action-mapping :
Here its giving an exception.
I think the issue is in the "name" or the "parameter" attribute.
I am really surprised why its giving the exception : javax.servlet.ServletException: Request[/dispatchAction] does not contain handler parameter named 'parameter'. This may be caused by whitespace in the label text.
Why are you not sending parameter from there. As I said, your Dispatch Action always expects a parameter called "parameter".
Change your global forward to
Change your action class to DispatchAction before you test, after above change
Joined: Feb 23, 2007
I changed my action to DispatchAction. It worked and its showing the add page. But what I want is the dispatchAction.jsp page which has all the links and when click on the link then it would show the page. Basic aim is this.