Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic jsp

 
sachin cknd
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear everybody,
i am new to jsp and facing very prilimary problem.
i have a html page as
********* HTML **********
<html>
<body>
<form action="demo.jsp" method=post>
Name <input type=text name=fname>
<input type=submit>
</form>
</body></html>
*****************

and my jsp page is
********** JSP **********
<html>
welcome<br><br><br>
<%
String name=request.getParameter("fname");
out.println("Name :"+name);
%>
Name : <%=name %>
</html>
*****************

i am getting html patr of the jsp file
but not getting dynamic part that is generated in the script.

*********** OUTPUT *****
welcome
*******

not getting Name : XYZ
can any body tell me the corrections in the code or why the output is not displayed?
thanks in advance
 
akshay mahajan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried running the same it is working very much fine. Just see whether u are running a proper sewserver
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks to me like your JSP is missing a couple lines of code
String name=request.getParameter("fname");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Name :"+name);
------------------
Dont blindly believe everything I say.
 
Ajan Balakrishnan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall do we really need to get the "out" object explicitly in a jsp . I thought it is an implicit object. Correct me if i'm wrong
Thanks
Ajan
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could well be correct. I dont know JSP very well.
 
sachin cknd
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by akshay mahajan:
i tried running the same it is working very much fine. Just see whether u are running a proper sewserver

akshay mahajan
i am using TOMCAT Version 3.2.1 as a webserver.
jdk1.2.2
can you please tell me which one you have used.
i will try with that one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic