| | |
JSP and Servlet Display of text in a text field
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Feb 2007
Posts: 4
Reputation:
Solved Threads: 0
Hello Friends,
I am trying to learn JSP, Servlets at the moment.
What am trying to do : A simple text field and a button
What should happen : When you click the button a text should appear something which is specified in the code. for example, "Pradeep".
I am really finding it difficult at the moment to actually bring the JSp and Servlet in connection.
Can anyone help me??
It would be great to start of with a problem to be solved an dthen move ahead.
Thanks and Rgds,
Pradeep (KINO)
I am trying to learn JSP, Servlets at the moment.
What am trying to do : A simple text field and a button
What should happen : When you click the button a text should appear something which is specified in the code. for example, "Pradeep".
I am really finding it difficult at the moment to actually bring the JSp and Servlet in connection.
Can anyone help me??
It would be great to start of with a problem to be solved an dthen move ahead.
Thanks and Rgds,
Pradeep (KINO)
the button (when activated) submits a post request to the servlet, the servlet sets some information in the http requests and forwards to the JSP.
What part of that don't you get working? It's rather basic...
What part of that don't you get working? It's rather basic...
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
•
•
Join Date: Feb 2007
Posts: 4
Reputation:
Solved Threads: 0
•
•
•
•
the button (when activated) submits a post request to the servlet, the servlet sets some information in the http requests and forwards to the JSP.
What part of that don't you get working? It's rather basic...
Index.jsp :
--------------------------------------------------------------
<html>
<head>
<title></title>
</head>
<body>
<h2></h2>
<form method="post" action="displayname">
<% String name="";%>
<% if(request==null){
name="";
}
else{
name=request.getParameter("name");
}
%>
Display Name:
<input type="text" name="name" value=<%=name%> />
<br>
<input type="submit" name="display" value="Display" />
</form>
</body>
</html>
-------------------------------------------------------
HelloServlet.java
-----------------------------------------------------------------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloServlet extends HttpServlet{
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
request.setAttribute("name", "Pradeep");
getServletContext()
.getRequestDispatcher("/view.jsp").forward(request, response);
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
getServletContext()
.getRequestDispatcher("/view.jsp").forward(request, response);
}
}
--------------------------------------------------------------
Any wrong in this code??
please help me try to debug.. Thanks a lot!
- KINO
![]() |
Similar Threads
- Searching a Text Field in a JList (Java)
- Text field does not enable on refresh (JavaScript / DHTML / AJAX)
- Filtering My sql through Php using drop down menu and text field (PHP)
- getting the text field value (HTML and CSS)
- DOB field-how to use text field and pop out calendar same time? (ASP)
- Output MySQL text field formatted (PHP)
Other Threads in the JSP Forum
- Previous Thread: Problem adding registration data to mysql database
- Next Thread: Communication Link Failure Error
Views: 6397 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






