Tuesday 15 January 2013

java - Pull info using a servlet and display on JSP -


After

I do not believe this is the correct terminology, but I want to remove some information from a servlet and display it My JSP page is

This is what I am using in the servlet.

Protects Zero ProcessRequest (HttpServletRequest request, HttpServletResponse response) throws ServiceExtension, IOException {response.setContentType (" text / html; charset = UTF-8 "); Try (print out = feedback. Gate witter ()) {/ * TODO Output your page here. You can use the following sample code * / out.printline ("& lt ;; DOCTYPE html & gt;"); Out.println ("& lt; html>"); Out.println ("top> gt;"); Out.println ("and lieutenian; title & gt; servlet account negotiable & lt; / title & gt;"); Out.println ("& lt; / head>"); Out.println ("k & lt; body & gt;"); String i, id, type; Double hair; I = request.getParameter ("custid"); Try {account c1 = new account (); C1.selectDB (i); Id = c1.getCid (); Typ = c1.getType (); Hair = C1. Balance (); } Hold (exception e) {System.out.println (e); } Out.println ("& lt; / body & gt;"); Out.println ("& lt; / html>"); }}

Whether this servlet is doing, just get a user ID from the main jsp page and then run an object that connects Databases and all the necessary information pulls it all working smoothly. Now, by the bridge, do I mean that when the user clicks the View button on the main jsp, it should be run (not redirected) servlet, the servlet is above all After that the information displayed will be in it The main jsp is obtained in X

Thank you!

"itemprop =" text ">

You need to call Ajax to use servlet and get data back quietly to do this Here's an example of a GET request to click on the button here:

  $ ( '# Button-id-goes-here'). Click (function () () ($) .get ("your-url-for-servlet", function (data) {// data servlet $ ("# view-id-goes-here"). Data);});});  

What is this code simple? When the button is clicked, the servlet URL is called and then sets the response data in the view of the given ID. Sets the data as HTML content but you can play with options.

Check this link:


No comments:

Post a Comment