Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestProcessor not able to find the Action class

 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created a Sample.jsp in jsp folder (At the same level as WEB-INF). I have a populate() javascript funtion which is making an AJAX call to the Action Class named PopulateSampleAction. For making the AJAX call I have created a url string as
var url="populateSample.do?

In strutsConfig.xml I'm also doing the following mapping
<action path="/populateSample" type="PopulateSampleAction">

When I run the JSP the control is not reaching the PopulateSampleAction class, and I'm receiving the following message at the console:

[12/5/06 18:01:40:651 IST] 5095b529 RequestProces E org.apache.struts.action.RequestProcessor Invalid path /jsp/populateSample was requested


This problem is only comming when I have put the sample.jsp file in the jsp folder, if I remove the file from that folder and put it in open along with WEB-INF, the control is reaching the PopulateSampleAction class and everything is working fine from there on.

I'm totally confused as to why the requestprocessor is not picking up the <action path="/populateSample" type="PopulateSampleAction"> from the struts config file and why it is taking the /jsp/ folder into consideration.

Is there any configuration setting that we need to do for adding the folders to keep the jsp's segregated?
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that the problem is related to this: "var url="populateSample.do". I am not sure how you are using this variable in your code. It appears that is that it is being interpreted as being relative to the current page (since it does not start with a /) so that is where the jsp part of the URL is coming in.

- Brent
 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brent,
The var url is used as a URL string that is used to make an AJAX call in the javascript funtion. Please have a look a the javascript code snippet below:

--------------------------------------------------------
function populate(){
var selectedValue=document.getElementById("id1").value
if(window.ActiveXObject){
var url="populateSample.do?selectedValue="+selectedValue;
req= new ActiveXObject("Microsoft.XMLHTTP");
req.open("GET",url,true);
req.onreadystatechange = getValue;
req.send();
}
}
--------------------------------------------------------

The above javascript call is made on the following jsp tag:

<TD>sample1: <html:select property="id1" on change="populate()">
 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any updates on this issue?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe Brent gave you the correct answer. If you want the URL to be valid regarless of your current context, you must specify url="<%=request.getContextPath()%>/populateSample.do".
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry...some times my boss expects me to actually get some work done and I don't get much time to drop in on the forum. ;-) Merrill's response looks like what I was thinking.

- Brent
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic