This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading paramater from URL in JSP  RSS feed

 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All
I am trying to do the following and i am getting an error.

In Servlet
response.sendRedirect("http://localhost:8080/PBS/StockTransferSuccess.jsp?itmname:" +itmname);

and IN JSP
<%
String sItemName = request.getParameter("itmname");
out.println("<B><U>Item Name:"+sItemName+"</B></U>");
%>

i am not getting the Item No in JSP. It says the ITEM NO is null.

any ideas guys why does it do this to me?

regards,
Rashmi Trivedi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must use "=" between the paramater name and its value, not ":".

response.sendRedirect("http://localhost:8080/PBS/StockTransferSuccess.jsp?itmname=" +itmname);
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks satou
I will test the code shortly.

Just for my information:
I can pass the paramater same between JSP as well. please see the code below and let me know if i am doing anything wrong.

<form name="warehouse" method="post" action="ViewInovice.jsp?sItemNane="+sItemName>

Please let me know your thoughts.

Thank you once again..much appreciated.

regards,
Rashmi Trivedi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a form, you should use hidden fields instead:
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Satou
I will try this code and let you know the result.

regards,
Rashmi Trivedi
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satou
I tried the hidden field in JST and it didn't work.

This is what i want to do.

A.jsp has sItemNo and i would like to pass it to B.jsp for SQL Query to run.

I have tried the hidden filed and it didn't work. I have tried the action="B.jsp?sItemNo="+sItemNo This didn't work either.

Could you please suggest of give me an example if you can,

thanks and regards,
Rashmi Trivedi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you're submitting the form correctly ?
When you say that it does not work, what do you mean exactly ?
Anything inside the form will be sent properly. First, you can check that the value is set, by looking at the HTML source (A.jsp) from your browser.
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satou
When i tried with hidden filed, sItemNo value didn't go through to b.jsp. The code was exactly the way described in your resonse.

I got JSP working now with response.redirect statemment however i would like to see if i can get it to work with hidden field.

IS it possible to send me an example with hidden code so that i can compare with what i was doing wrong?

thank you for your time...much appreciated.

reards,
Rashmi Trivedi
 
Rashmi Trivedi
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satou
Hidden field works just fine.

Thank you so much for your help..

regards,
Rashmi Trivedi
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you made it work :thumb:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!