Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9182037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:27:54+00:00 2026-06-17T18:27:54+00:00

I have a problem calling a servlet, so I need help. Here is my

  • 0

I have a problem calling a servlet, so I need help.
Here is my web.xml

<servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/test/*</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>ajaxServlet</servlet-name>
        <servlet-class>org.finki.exercise.servlet.AjaxServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ajaxServlet</servlet-name>
        <url-pattern>/ajaxServlet/*</url-pattern>
    </servlet-mapping></servlet>

I have a jsp page for test purpose , where I amm trying to invoke servlet from ajax

<a href="#" onclick="loadXMLDoc('eva')">proba</a>

ajax fun

function loadXMLDoc(value1)
            {
                var xmlhttp;
                
                var url="ajaxServlet";
                if (window.XMLHttpRequest)
                {
                    xmlhttp=new XMLHttpRequest();
                }
                else
                {
                    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange=function()
                {
                    if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                        
                        document.getElementById("mid_title").innerHTML=xmlhttp.responseText;
                    }
                }

                xmlhttp.open("GET", url+"?url="+value1, true);
                xmlhttp.send();
            }

function loadXMLDoc invoke the dispatcher servlet http://localhost:8097/mavenproject1/test/ajaxServlet.
How to invoke ajaxServlet – http://localhost:8097ajaxServlet?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:27:55+00:00Added an answer on June 17, 2026 at 6:27 pm

    ajaxServlet doesn’t have a leading /, therefore it’s interpreted as a relative path. So if you send a request to ajaxServlet from http://localhost:8097/mavenproject1/test/foo, request will be sent to http://localhost:8097/mavenproject1/test/ajaxServlet.

    So, you need to add a leading /. But it’s not enough, because you also need to add context path of your application (/mavenproject1). In JSP page you can do it automatically as follows (assuming that you imported JSTL tag library):

    var url= "<c:url value = "ajaxServlet" />";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem regarding xml calling to REST web service, I have to
i have a problem calling multiple instance of a class that i have coded
I have a problem with calling an overriden method from java class. I have
I have a problem in calling a template class I have. I declared a
I have some problem with calling web service from flex. I have service with
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have a problem in calling my rand_id() function. here is code as <?php
I have a problem calling a static method from a class. Let me explain
I have a problem with calling .Net web services with a Firefox client. A
I have a peculiar problem when calling a web service that expects the message

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.