Shanmugapriya
Shanmugapriya

Reputation: 57

passing data between two jsp pages using jquery

I know this question seems already asked.. But i surfed through the websites and i did not get any clarification. Here is my question. I have two web pages. Call them as page1.jsp and page2.jsp. I am having a table in my page1.jsp. Please refer the image Please refer the image

And in my page2.jsp i am having an input field like in the following image enter image description here

Now I need to display the the respective docId in the textarea which i am clicking in the page1.jsp.

For example if i am clicking 00001 in page1.jsp i needs to redirect to page2.jsp and 00001 should be updated textarea of in page2.jsp

the script i used in page1.jsp is

$('.pending_list').click(function(){
            var row = $(this).closest("tr"); 
            var text = row.find(".pending_list").text(); 
            alert(text);
            var DocNo = text;
            $('.pending_list').attr({
                href:"${loginbean.contextPath}/effortloading/search"

            });         
        });

Here is my page2.jsp

<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
                                            <div class="row padding6">
                                                <div
                                                    class="col-lg-4 col-md-4 col-sm-4 col-xs-12 margintop8  rq-field">
                                                    <!-- for field required notification-->
                                                    <spring:message text="Doc No" />
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                                    <form:input id="docID" path="DOC_ID" name="DOC_ID" type="text"
                                                        class="form-control" />
                                                    <form:errors path="userTitle" class="control-label" />
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"></div>
                                            </div>
                                        </div>

Controller

@RequestMapping(value = "/effortloading/search", method = RequestMethod.GET)
    public String effortloadingsearch(@Valid @ModelAttribute("loginbean") Loginbean loginbean,EffortLoadingBean effortBean, Model model,BindingResult result){
        model.addAttribute("effortloadingedit", effortBean);
        return "EffortLoadingSearch";
    }

I hope my question is understandable. Thanks in advance

Upvotes: 0

Views: 133

Answers (2)

As a bare minimum you can pass your docId in the url itself from page1 and then later in page2 you can get it from your url and put it in the search area.

A little code to understand

In page1 :

    $('.pending_list').click(function(){
        var row = $(this).closest("tr"); 
        var text = row.find(".pending_list").text(); 
        alert(text);
        var DocNo = text;
        $('.pending_list').attr({
            //SEND YOUR DOCID IN THE URL
            href:"${loginbean.contextPath}/effortloading/search?docId=" + GET_ID_HERE
        });         
    });

Upvotes: 1

sachin gupta
sachin gupta

Reputation: 1

While forming the URL of 00001 in page1.jsp you can append query parameter and this query parameter can be used in second page to populate the text area.

Upvotes: 0

Related Questions