File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP Forms Text box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Forms Text box" Watch "JSP Forms Text box" New topic
Author

JSP Forms Text box

Anu Iyer
Greenhorn

Joined: Nov 03, 2005
Posts: 5
Hi,

I am running into this problem when I try to submit a form.
I enter value in a text box field(name) in the form (with white spaces) for eg Anu Iyer, and this form action is a jsp program which receives the parameter as follows:

String Name;
Name = request.getParamater("name");

When print the Name field in the JSP program I get only Anu. Everything after the white space is cut.

Form is submitted using POST.

Can you please help me?

Thanks
Anu Iyer
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

That's usually an indication of a quoting problem somewhere along the line. But we need to see your code to be sure.

Please post the relevant pieces of code, and please use the UBB code tags to preserve the code formatting (see the CODE button below the text entry area).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Sounds like you don't have quotes in your input field.


<input type="text" value=<jsp tag to print value> >

In which case the browser will only recognize the string that is directly up against the equals sign.






[KLUNK!]
[ November 03, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

[KLUNK!]


We really need to come up with a "head-bumpers" smilie!
Anu Iyer
Greenhorn

Joined: Nov 03, 2005
Posts: 5
Heres the code:

Form (HTML code)

<form METHOD=GET NAME="cdms" onSubmit="return checkForm();" action="submit_work_request.jsp">
.
.
.
<tr bgcolor="SILVER">
<td valign=top>
<input type="text" name="title" value="" size=15 maxlength=20></td>
<td valign=top>
<b>Title</b>
<br>

Submit_work_requst.jsp
<%@ page import="java.util.*" %>

<%@ page import="java.sql.*" %>

<%@include file="header.jsp"%>
<BR>
<HEAD>
<%! String wr_nbr, development_team_lead, title, priority, description, business_approver; %>
<%
wr_nbr = request.getParameter("wr_nbr");
development_team_lead = request.getParameter("development_team_lead");
priority = request.getParameter("priority");
business_approver = request.getParameter("business_approver");
title = request.getParameter("title");
description = request.getParameter("description");
%>
Anu Iyer
Greenhorn

Joined: Nov 03, 2005
Posts: 5
<form METHOD=POST NAME="cdms" onSubmit="return checkForm();" action="submit_work_request.jsp">

This is what I tried not GET method.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Firstly, in



get used to quoting all values. So it should be



Getting into this habit will save you heart-ache and pain in the future.

Secondly, you didn't show us how you are displaying the value.

Thirdly, please surround your code with UBB code tags. For example:

[CODE]
Here is where the code goes.
[/CODE]

This will help it stand out and will preserve its formatting.
[ November 03, 2005: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

<%! String wr_nbr, development_team_lead, title, priority, description, business_approver; %>


This is going to cause you a lot of headaches as well.
Any variables declared inside a <%! %> block are instance variables.
They are shared among all requests to that JSP and are, thus, not thread-safe.
Anu Iyer
Greenhorn

Joined: Nov 03, 2005
Posts: 5
Thank you Thank you much. Yes, I quoted the values and I also removed the ! in the String Declare. It works perfect now.

Thanks!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Forms Text box
 
Similar Threads
in dropdown problem
Submitting a form on pressing Enter key
Passed SCWCD/OCPJWCD 5 with 92%
Null Pointer in struts
Problem in Validating array of form field