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

  • SEARCH
  • Home
  • 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 9158603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:17:13+00:00 2026-06-17T13:17:13+00:00

I have recently started working with Spring MVC framework. I made a lot of

  • 0

I have recently started working with Spring MVC framework. I made a lot of progress while reading lots of tutorial on the net.

Background about my application-

I have to make a REST URL call to another service (deployed already on tomcat) by using details provided in the form. So I have already made a form using JSP whose content is something like this as shown in the picture- I am not sure how can I make a REST url call by making the url from the form entries and then show the response of that url on the next screen.

So in the above form if I have written User Id as 1000012848 , and checkbox is selected (means true) for Debug Flag and in the Attribute Name I have selected first row ( in general we can select all three as well) and Machine Name is localhost and Port Number is 8080 then url should look something like this-

http://localhost:8080/service/newservice/v1/get/PP.USERID=1000012848,debugflag=true/host.profile.ACCOUNT

So in all our URL that we will be making from the form entries, the below line will always be there at the same place- and then after that each form entry will start getting appended

service/newservice/v1/get/

Now after making the above url, as soon as I will be clicking submit, it will be making a call to the above url and whatever response it gets from the URL, it will show in the next screen (result.jsp file) which I am not sure how to do that? Below are my files which I have created. Can anyone help me out in solving my problem? What code changes I will be needing to do this problem?

student.jsp file (which makes the form)

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<res:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
    <title>First Tutorial</title>
</res:head>
<res:body>

    <form:form method="POST" action="/_hostnewapp/addStudent">
        <table>
            <tr>
                <td><form:label path="userId">User Id</form:label></td>
                <td><form:input path="userId" /></td>
            </tr>
            <tr>
                <td>Debug Flag :</td>
                <td><form:checkbox path="debugFlag" /></td>
            </tr>
            <tr>
                <td>Attribute Name</td>
                <td><form:select path="attributeNames" items="${attributeNamesList}"
                        multiple="true" /></td>
            </tr>
<!--        <tr>
                <td>Environment</td>
                <td><form:checkboxes items="${environmentList}"
                        path="environments" /></td>
            </tr>
 -->            
            <tr>
                <td><form:label path="machineName">Machine Name</form:label></td>
                <td><form:input path="machineName" /></td>
            </tr>
            <tr>
                <td><form:label path="portNumber">Port Number</form:label></td>
                <td><form:input path="portNumber" /></td>
            </tr>

            <tr>
                <td colspan="2"><input type="submit" value="Submit" /></td>
            </tr>
        </table>
    </form:form>

</res:body>
</html>

result.jsp file (which I am going to use to show the result after hitting that url)

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<res:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="layout" content="main" />
    <title>HostDomain</title>
</res:head>
<res:body>

    <h2>Response after submitting the result</h2>
    // Not sure what I need to add here to show the result after hitting the url

</res:body>
</html>

Controller Class-

@Controller
public class SampleRaptorController {

    @RequestMapping(value = "/student", method = RequestMethod.GET)
    public ModelAndView student() {
        return new ModelAndView("student", "command", new Student());
    }

    @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
    public String addStudent(@ModelAttribute("SpringWeb") Student student,
            ModelMap model) {
        model.addAttribute("userId", student.getUserId());

        return "result";
    }


    @ModelAttribute("attributeNamesList")
    public Map<String,String> populateSkillList() {

        //Data referencing for java skills list box
        Map<String,String> attributeNamesList = new LinkedHashMap<String,String>();
        attributeNamesList.put("ACCOUNT","host.profile.ACC");
        attributeNamesList.put("ADVERTISING","host.profile.ADV");
        attributeNamesList.put("SEGMENTATION","host.profile.SEG");  

        return attributeNamesList;
    }
}
  • 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-17T13:17:14+00:00Added an answer on June 17, 2026 at 1:17 pm

    You can to use RestTemplate for calling RESTful URLs from your spring component

    So, Your controller method can be as below

    @Controller
    public class SampleRaptorController {
    
        @Autowired
        RestTemplate restTemplate;
    
        @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
        public String addStudent( @ModelAttribute("SpringWeb") Student student,
                        Model model){
    
            // Build URL
            StringBuilder url = new StringBuilder().
                            append("http://localhost:8080/service/newservice/v1/get").
                            append("?PP.USERID=" + student.getUserId).
                            append("&debugflag=" + student.isDebugFlag);// so on
    
            // Call service
            String result = restTemplate.getForObject(url.toString(), String.class);
            model.addAttribute("result", result);
    
            return "result";
        }
    
    }
    

    Your spring configuration should register the restTemplate as below:

    <bean id="restTemplate" class="org.springframework.web.client.RestTemplate"/>
    

    See RestTemplate doc for more details.

    The above should do.

    One suggestion.. Your RESTful URL (http://localhost:8080/service/newservice/v1/get/PP.USERID=1000012848, debugflag=true/host.profile.ACCOUNT) is really terrible. Once you resolve your problem, I recommend you to google for how a good RESTful URL shuld look like.

    Cheers,
    Vinay

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently started with ASP.NET and MVC and have a few questions on working with
This is a very elementary I realize, I have recently started working with asp.net
I have recently just started working with Lucene (specifically, Lucene.Net) and have successfully created
I recently started working with Eclipse to build Android Applications. I have made a
I have only recently started working with the MVC approach, so I suppose this
I recently started working with Dojo framework and have to make floating panes for
I have recently started teaching myself C# and Asp.net. I am trying to build
I have recently started working on my master thesis in C that I haven't
i have recently started working on C# and i am very amateur at it
I have recently started working on an app which has both Java and native

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.