• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Forms Text box

 
Anu Iyer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[KLUNK!]


We really need to come up with a "head-bumpers" smilie!
 
Anu Iyer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%! 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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Thank you much. Yes, I quoted the values and I also removed the ! in the String Declare. It works perfect now.

Thanks!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic