Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP doubt  RSS feed

 
Vasudevan Gopalan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have two doubts.

1. I am having text box like this
<input type =text value="<%=request.getParameter("name")%>" >
If name parameter is null it is showing as "null" in textbox.Is there any way to show the textbox as blank instead of "null" text.Do i need to write a method for this.

2. Is there any way to Trim the values like Trim function in ASP
Regards,
Vasu
 
jyothsna kumari
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,
for the first doubt u can like this,
<input type =text value="<%if(request.getParameter("name")!=null{%><%=request.getParameter("name")%><%}%>">
 
Vasudevan Gopalan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this.I am asking whether any already existing function is there .
 
Ning Du
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No,I think.
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a servlet filter to intercept the request before it gets to your page. In the filter, you get the value of the parameters, manipulate them however you like, and set them as request attributes of the same name but new value. Then, in your serlvet/jsp, you use request.getAttribute instead of request.getParameter.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!