• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Need help with a servlet problem

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Java Gurus,

I am working on a simple web project and need help with a problem.

The index.jsp has 2 iframe components, where the src attribute for each iframe references to a separate jsp page (so the src for iframe1 is iframe1.jsp and for iframe2, its iframe2.jsp)

Now, the iframe2.jsp has a search text and a submit button. On entering a search text, the control goes to a servlet, which then runs some logic and sends an object to be displayed in iframe1.

In the servlet, I have used RequestDispatcher to forward the response to iframe1. Now, the problem here is that the response is getting populated in iframe2.jsp itself (from where the initial request originated). I need to response to go to iframe1.jsp

Have verified all the links and paths in the code, so there isn’t any typo anywhere. Just wondering what might be wrong here. Is RequestDispatcher not the right way to send control to another jsp? If yes, what is the other alternative?

Please advise.

Thanks,
B.S.S
 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This problem may occur because

1.When you are testing your webapps try to clear the history of the browser after sometime because older code get reflected again and again and you think there is error is you code.but actually browser is behaving differently

2.Can you please tell which server you are using.have you deployed your war file on server or you are just using eclipse feature.
 
pradeep andhra
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Shanky Sohar wrote:This problem may occur because

1.When you are testing your webapps try to clear the history of the browser after sometime because older code get reflected again and again and you think there is error is you code.but actually browser is behaving differently

2.Can you please tell which server you are using.have you deployed your war file on server or you are just using eclipse feature.



Hi Shanky,

I am using netbeans version 6 for my project. I dont think this has anything to do with browser cache or history. Its about the control being passed from servlet to a jsp which is different from the jsp that has initated the request.

Thanks,
B.S.S
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please tell which server you are using and have you deployed your war file on the server.
 
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Instead of using the Submit button try using the hyperlink <a href="" target="Frame Name">. Input html tag doesnt have the target attribute but the target attribute is supported in the HTML <a> tag. In case of Submit button the response is redirected to the current frame. Hope this helps in resolving the above problem

Kuldip
 
Greenhorn
Posts: 23
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It seems that you are not having any problem with passing the control. Submit button works just for the form submission and have no responsibility to render pages in specific regions.
You can use hyperlink and java script to handle form submission, and getting it in another frame.

-Tejas
Cherish your life...!!
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please post the code..So that we can see.
 
pradeep andhra
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tejas Shah wrote:Hi,

It seems that you are not having any problem with passing the control. Submit button works just for the form submission and have no responsibility to render pages in specific regions.
You can use hyperlink and java script to handle form submission, and getting it in another frame.

-Tejas
Cherish your life...!!



Sorry for the delay in replying to this thread.

Tejas - Yes, the problem is similar to what you have stated.

The code below gives you an indication of the issue

index.jsp - the page that contains the 2 iframes



Here is frame1.jsp which is put in a folder named frame1.



Here is frame2.jsp which is put in a folder named frame2.


And finally.. the servlet code


Instead of frame1 getting the message from the servlet, the frame2 is always getting populated with this message.

Please advise.

Thanks,
B.S.S
 
Kuldip Shetty
Ranch Hand
Posts: 45
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pradeep,

As mentioned above did you try using the hyperlink with target attribute instead of submit button. I tried with some sample static HTML files with frames (without using servlets) which uses <a> hyperlink with target attribute and I was able to redirect the response to another frame. But using a submit button, as you mentioned was displayed in the same frame.

Below is the sample of frame2.html which has the hyperlink example



Kuldip
 
pradeep andhra
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kuldip Shetty wrote:Pradeep,

As mentioned above did you try using the hyperlink with target attribute instead of submit button. I tried with some sample static HTML files with frames (without using servlets) which uses <a> hyperlink with target attribute and I was able to redirect the response to another frame. But using a submit button, as you mentioned was displayed in the same frame.

Below is the sample of frame2.html which has the hyperlink example



Kuldip



Thanks Kuldip. But I really need to push this to a servlet and that's because I have a whole lot of logic (database calls and dicing the information) at the backend.

Any idea how I can get this done?

Thanks,
B.S.S
 
    Bookmark Topic Watch Topic
  • New Topic