Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jsp called multiple servlet and remain in the same page

Posted on 2003-11-09
4
Medium Priority
?
625 Views
Last Modified: 2013-11-24
Dear Expert,

I have 2 components, one is JSP (test.jsp), the other is Servlet.

The JSP act like the User Interface to accept 3 parameters from the user.

The servlet will perform calculation based on a SINGLE parameter sent from the JSP.

After the user input 3 parameters,
1. How to call the Servlet 3 times in the same time (since the serlvet only calcuate one parameter)?
2. Let the user remain in the test.jsp while the servlet perform the calculation ?
3. How jsp can get the calculation result from the servlet ?

Thanks
Vince



0
Comment
Question by:vincehon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:dualsoul
ID: 9712889
hm...why do you want to call your servlet 3 times?

i think it's more suitable to get all parameters from user -> call servlet, which will calcalate result -> reirect to result .jsp page, providing result info as JavaBean
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9712899
I don't know why your JSP contains three input fields when you are only going to process one in the servlet.  Why can't you do all three in one go?  How does the servlet know which one you want to process (are they in three different forms)?

When you press your submit button, the servlet will be called to process the results.  When it has finished, it should redirect back to the JSP including any calculation results as parameters.  In the JSP, you should check to see if any result parameters are present and if so, display them.

When the JSP is first called (presumably from a link), the URL won't contain any result parameters, so none should be displayed.

If this is simply a case of performing a calculation based on the user input (ie. if it doesn't require server-side data), why not just do this with JavaScript?  That way, the page won't change at all (apart from displaying the results of the calculation).
0
 

Author Comment

by:vincehon
ID: 9719497
Thx for all reply, I just want to simplier the situation.
Here is my web application:

I would like to set up a web site that allow user to sent SMS.

For the front end
test.jsp
- ask the user to input parameter, like the sender phone no., receive phone no, the SMS message....

For the back end.
1. It has a RouterServlet
- to accept the parameters and find the best route.
- based on the best route, relay the SMS request to other component,
known as ESMEServlet (also a Servlet)

2. ESMEServlet
- the ESMEServlet will then sent the SMS to the SMS service center.

If I split the multiple phone on RouterServlet, let say, there are 3 phone numbers. RouterServlet will call ESMEServlet 3 times.

-------------------------------------------------------------------------
As you can see, there are 3 tiers.
test.jsp --> RouterServlet --> ESMEServlet

The difficulty is that I need to get the return flag on each tier.
For the test.jsp --> RouterServlet
I need to know whether RouterServlet can successfully accept the SMS request from test.jsp

Once I get the return flag from RouterServlet, I will used this to inform the user whether his/her SMS sending is successfully or not.
If success, I will debit his bonus point.

For the 2nd tier
RouterServlet --> ESMEServlet.
Same as test.jsp --> RouterServlet. RouterServlet will also need to get the return flag from ESMEServlet to indicate whether ESMEServlet is invoked successfully or not

My question is:
1.How can I get the return from RouterServlet and inform this to the user on the test.jsp page?

2. for the test.jsp --> RouterServlet.
Assume RouterServlet can return the flag after it is executed 50%. Is it possible to return the flag from RouterServlet to test.jsp and then let the RouterServlet to execute the remaining part (in this case, RouterServlet will invoke ESMEServlet) ? I want to do this because I do not want the user to wait for a relative long period of time.

3. Is it possible for 2 different Servlets to cooperate in thread ? i.e. one continue to execute until the other has completed certain task. (like RouterServlet and ESMEServlet in my case)

0
 
LVL 15

Accepted Solution

by:
dualsoul earned 600 total points
ID: 9720184
1. i can't understand why you want to return something from RouterServlet. Just redirect from RouterServlet to result page (test_result.jsp for instance of even back to test.jsp, if you so like it), to pass some data from servlet (return flag fot instance) pack you data to JavaBean and pass it to .jsp.

2.  so, you can certanly call RouterServlet, and after it's finihed, call EMSServlet, what's trouble? Just don't call EMSServlet from RouterServlet. Call it standalone.
But in my opinion you should think/read about MVC paradigm, you have very strange design.

3. why?!
Think about design, may be you shouldn't use servlets to execute your tasks, may be to code special classes for it?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question