1

I have a JSP page called CreateProcessGroup.jsp and I use an annotation controller to map requests to CreateProcessGroup.htm to that page. But I'm having an interesting issue when I request the page from browser it works, when send a request using jQuery $.get method I get 404 (CreateProcessGroup.htm not found) is there a difference between two requests?

My JSP page just under WebContent dir and JS file under WEBContent/Jquery my function sending the request like below:

function SendCreateProcessGroupRequest()
{
var pid = $('#pid').val();
var description = $('#processGroupDescription').val();

var x = "/CreateProcessGroup.htm";
alert(x);

$.get(x, { pid: 62, description: description },
           function(data){
             alert("Data Loaded: " + data);
           });
}

Do I need to give the URL as ../CreateProcessGroup.htm? Indeed I tried:

  • /CreateProcessGroup.htm
  • ../CreateProcessGroup.htm
  • /../CreateProcessGroup.htm
  • ../../CreateProcessGroup.htm
  • /../../CreateProcessGroup.htm

My guess is DispatcherServlet can not map Ajax requests to Controllers but this is stupid isn't it?

How can i get rid of the situation?

Thanks all.

6
  • Where is the page that's running this, and where is CreateProcessGroup, both with respect to the root of the site? Commented Aug 14, 2010 at 11:36
  • yes CreateProcessGroup.jsp and the running page ProjectDetail are both under the WebContent folder. Commented Aug 14, 2010 at 11:38
  • @mehmet6parmak - What does var x="CreateProcessGroup.htm"; (nothing before it) do? Commented Aug 14, 2010 at 11:40
  • i had some caching issues with tomcat i just used that to see whether my changes are reflecting or not is that matter? Commented Aug 14, 2010 at 11:43
  • @mehmet6parmak - Oh no that's fine, I just didn't see without a slash in your attempts list. Without one i'll make a request beside the current page, if the pages/handlers are siblings in the hierarchy, it should work without the slash. Commented Aug 14, 2010 at 11:47

1 Answer 1

2

Try this instead:

var x = "CreateProcessGroup.htm";

If the page you're requesting is beside the one making the request there's no need for a path in front, it will (by default) make a request to the same path just with that page/handler on the end.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.