Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

pass jsp values of textbox through servlet as entry point to other jsp file

Posted on 2004-10-09
5
Medium Priority
?
1,546 Views
Last Modified: 2006-11-17
pass jsp values of textbox through servlet as entry point to other jsp file:

i am having one jsp page with text boxes,
jsp page is requesting to entry servlet
i want to pass values which is redirected to other jsp

can you help, when i try to retrieve values i found them null


Regards
0
Comment
Question by:evaibhav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 1000 total points
ID: 12269600
in servlet coding do like this

request.setAttribute("TextBoxValue",request.getParameter("TextBoxValue"));
RequestDispatcher dispatcher = getRequestDispatcher ( "yoursecondjsp.jsp" );

if ( dispatcher == null ) {
            throw new Exception ( "Unable to find yoursecondjsp.jsp " );
            }
      //      Pass control to the jsp page , which will write directly to the output stream.
      dispatcher.forward (request, response);

----
in second jsp

String textBoxValue=(String)request.getAttribute("TextBoxValue");



0
 
LVL 19

Assisted Solution

by:Kuldeepchaturvedi
Kuldeepchaturvedi earned 1000 total points
ID: 12296853
if you are using dispatcher.forward then you need not to set attribute. in forward the request object is passed as is so in the second jsp you should be able to do a simple request.getParmaeter("TextBoxValue") and it should give you the values.
I think the problem is that you are using .redirect() method. redirect makes a new request and response and as a result setAttribute will not work either.

if you have to use redirect then its better to put your values in session and retrive it from there...
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12537275
:)
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read on to get a few ideas on how to promote your next corporate event.
Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question