I have shared a part of my code and in the Class 'Room',variable 'nw' has the query string value.Now,I want the html 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.html")
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 html file
<html>
<head>
<link rel="stylesheet" href="{{ static_url("css/registration.css")}} />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<c:import url="InnerHeader.js"></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" >                
<input type="submit" value=" Submit " /></td>
</tr>
</table>
</fieldset>
</form>
</center>
The following link helped me figure out the answer:
How to pass arguments from tornado to a js file but not html?.
I added self.render("RoomPost.jsp",nw=nw) in tornado script and autofocus required value="{{nw}}" readonly/> in .jsp script.