lundi 27 novembre 2017

How to pass arguments from tornado to a jsp file?

I have shared a part of my code and in the Class 'Room',variable 'nw' has the query string value.Now,I want the .jsp file to autofill the 'nw' field with the query string value dynamically.How do I get that?Does self.get_namespaces help?

    class Room(tornado.web.RequestHandler):
    def get(self):
       nw=self.get_argument("nw")
       print(nw)
       self.render("RoomPost.jsp")  

class static(tornado.web.RequestHandler):
    def get(self,key):
           iname="static/" +key
    print iname
              self.render(iname)        
settings = {
    'debug': True,
    'static_path': 'static'}

application = tornado.web.Application([

        (r"/room",Room ),

        #(r"/static/(.*)",static)
        ], **settings)
if __name__ == "__main__":
    application.listen(5500)
tornado.ioloop.IOLoop.instance().start()

Following is the .jsp file

<html>
<head>
<link rel="stylesheet" href=" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

</head>
<body>
<c:import url="InnerHeader.jsp"></c:import>
<br><br><br>

<center>
    <form action="/room" method="post" >
    <fieldset>
        <legend>
            <b1>Room Add</b1>
        </legend>
        <table class="registerTable">
            <tr>
                <td>Name of NW/Name of Home</td>
                <td><input type="text" name="nw" placeholder="Kfx-Home"
                    maxlength="15" size="30" autofocus required/></td>
            </tr>

                <tr>
                <td colspan="2" align="center" > &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
                <input type="submit"     value="  Submit  " /></td>
                </tr>

        </table>
        </fieldset>
    </form>
</center>




Aucun commentaire:

Enregistrer un commentaire