java - null request response in simple jsp file -
i trying set basic jsp file takes in query url , displays it. have following test.jsp file run on server:
<%@ page language="java" contenttype="text/html; charset=iso-8859-1" pageencoding="iso-8859-1"%> <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>test jsp</title> </head> <body> <% string firstname = (string) request.getattribute("firstname"); out.println("hello :" + firstname);%> </body> </html>
however, when type in following url, still "null" result (even after refreshing): see picture.
note: ultimate goal have event @ point sends post request java file , display result in jsp page. if understood research, have via servlet dispacherrequest forwarding method. first want understand why simple aforementioned code isnt working).
thank !
you mention you're trying display query parameter url. query or request parameter not same request attribute.
to query parameter, have use getparameter()
method:
string firstname = request.getparameter("firstname")
Comments
Post a Comment