Jump to content

Jsp n html simple program

- - - - -

  • Please log in to reply
3 replies to this topic

#1
jugalrockz

jugalrockz

    Newbie

  • Members
  • Pip
  • 5 posts
Hello people,


I have configured TOMCAT6.0. I followed the following steps to configure:
1. Opened catalina n gave the path. JAVA_HOME="JDK1.6_PATH"
2. Opened CMD gave the tomcat path... STARTED THE SERVER.Then STOPPED IT
3. Installed Netbeans6.1, configured tomcat server in it.



Later i typed a simple program with JSP N HTML:
The following is the HTML code:
<html>

<head>
<title>HELLO WORLD123</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="index.jsp">
firstname<input type="text" name="firstname" value="username">
password<input type="password" name="password" value="password">
<input type="submit" value="submit">
</form>
</body>
</html>


JSP code:


<html>
<head>
<title>123</title>
</head>
<body>
<h2>Hello World!</h2>

<%
String firstname=request.getParameter("firstname");
String lastname=request.getParameter("lastname");
%>

<%=firstname%>
<%=lastname%>

<form action="newhtml.html" method="post">
<input type="submit" value="return">
</form>
</body>
</html>



When i save n run this program the browser is giving a diff output. It is showing the out of index.jsp. The output looks like the following:

Hello World!




Please help me solve this issue. What should i do now.

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
So to run, you open the html file, type in a name and password and press submit, right?
Where should the lastname come from, by the way?

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Also note you should add:
<form action="index.jsp" [B][I]method="post"[/I][/B]>
If you leave the method out, their password will automatically be pushed to the url (via GET instead of POST, i.e. index.jsp?firstname=...&password=...) which is possible security risk
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
jugalrockz

jugalrockz

    Newbie

  • Members
  • Pip
  • 5 posts
Thanks alot alexander.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users