• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AJAX Problem in JSP

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
Iam using AJAX in JSP ... Lets say EMAIL_COMPONENT is my application and MainPage.jsp is default page where iam going to run AJAX..

Now ,

When the url path is http://localhost:8080/EMAIL_COMPONENT/JSP/MainPage.jsp
AJAX is working perfectly right ...

but

when the url is http://localhost:8080/EMAIL_COMPONENT/

AJAX is not working at all ...

What is the problem .... ???
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is your context root? EMAIL_COMPONENT or EMAIL_COMPONENT/jsp?

How did you define the default page? MainPage.jsp or jsp/MainPage.jsp?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What URL are you using when making your AJAX call?

How are you building it?
Can you post the JSP code that is used to create the URL?
 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
Thanks for replying ... My context root is EMAIL_COMPONENT(Application Name) and i defined the default page as below in web.xml ...

<welcome-file-list>
<welcome-file>/JSP/MainPage.jsp</welcome-file>
</welcome-file-list>


My Web Folder Hierarchy ...

1)EMAIL_COMPONENT(Root)
1)JSP
2)JS
3)WEB-INF
 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jesus Angeles:
What is your context root? EMAIL_COMPONENT or EMAIL_COMPONENT/jsp?

How did you define the default page? MainPage.jsp or jsp/MainPage.jsp?



Hi ,
Thanks for replying ... My context root is EMAIL_COMPONENT(Application Name) and i defined the default page as below in web.xml ...

<welcome-file-list>
<welcome-file>/JSP/MainPage.jsp</welcome-file>
</welcome-file-list>


My Web Folder Hierarchy ...

1)EMAIL_COMPONENT(Root)

under this folder,
1)JSP
2)JS
3)WEB-INF
 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
What URL are you using when making your AJAX call?

How are you building it?
Can you post the JSP code that is used to create the URL?



Hi,
Thanks for replying....

Iam calling a JSP(Servlet) in javascript to get the response from it ....
Here is the url JAVASCRIPT code ...


var url = "GetEmailsServlet.jsp?sender_email="+AJAX_FIELD.value;
createXMLHttpRequest();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
xmlHttp.onreadystatechange = callback;
 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Please help me ASAP

This is my problem .....


I have a problem in running AJAX in JSP ...

Here " EMAIL_COMPONENT " is my web application and my default page
( configured in web.xml ) is MainPage.jsp .

Here is configuration in web.xml
--------------------------------

<welcome-file-list>
<welcome-file>/JSP/MainPage.jsp</welcome-file>
</welcome-file-list>

when i run my application with the url ,

http://localhost:8080/EMAIL_COMPONENT/

AJAX is not working ...

But when i explicitly hard code the url as below ...

http://localhost:8080/EMAIL_COMPONENT/JSP/MainPage.jsp

AJAX is working perfectly ....

Can anyone help me ASAP ....

Thanks in Advance ...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're using a relative URL when making your AJAX call.



Like any link in a JEE app, the best approach is to make the link relative to the context path, not the current file.
Try:


Or, if you're using JSP 1.2:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic