Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSP
how to prevent printing submit button name
shawn peter
Ranch Hand
Posts: 1325
1
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i am trying to get user name and age by a
jsp
and send them to
servlet
.
in the servlet i am printing all valus .but it also prints submit button names.
how to privet that.here is the code.
<%@ 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>Insert title here</title> </head> <body> <form action="getData" method="post"> <input type="text" name="name" id="x"><br/> <input type="text" name="age" id="y"><br/> <input type="submit" name="submit" value="Submit"> </form> </body> </html>
package serv; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class getData extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter pw=response.getWriter(); String name=request.getParameter("name"); String age=request.getParameter("age"); Enumeration e=request.getParameterNames(); while(e.hasMoreElements()){ String x=(String)e.nextElement(); String y=request.getParameter(x); pw.write(y); pw.write("\n"); } } }
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
If you don't want values for the submit buttons to be submitted, don't give them names.
By the way, "print" means to send to a printer.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
And another by the way,
never
name anything
submit
. it will cause all kinds of problems as you replace the form's submit method when you do this.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Problem regarding redirected error message
Getting NullPointerException
NULL
Error in request.getParameter
getParameter() method gives null
More...