Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old August 12th, 2002, 05:51 AM
tiago251 tiago251 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 14 tiago251 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question URL updating from a servlet dispatcher

Hi all!

I got a jsp page (MeetingQuery.jsp) with a form whose action is:

action="/Meeting/servlet/MeetingQueryProcess"


This servlet processes the request and then sends user back to MeetingQuery.jsp:

rd = request.getRequestDispatcher("/MeetingQuery.jsp");
rd.forward(request, response);


The problem is that in the URL we can see:

http://localhost:8080/Meeting/servlet/MeetingQueryProcess


Instead, I would like to see .../Meeting/MeetingQuery.jsp again. Is it possible and if yes, how to do that?
Thanks for your answers!
::Tiago

Reply With Quote
  #2  
Old August 13th, 2002, 03:09 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
You're going to have to force the browser to make a new request to the other page. You can either send back some javascript, meta refresh, or (at least with php) a location header. This will generate a new request object, though, so you won't be able to access anything from the original.
You might give the user a "query successful" mesage (like this board does when you post a reply), then redirect them to the jsp.

Reply With Quote
  #3  
Old August 16th, 2002, 06:20 PM
dhtmlkitchen dhtmlkitchen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Boston, MA
Posts: 30 dhtmlkitchen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
(deleted)
__________________
http://dhtmlkitchen.com/

Reply With Quote
  #4  
Old September 15th, 2002, 05:08 PM
dhtmlkitchen dhtmlkitchen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Boston, MA
Posts: 30 dhtmlkitchen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Solution

The solution to this problem is not hard, but it required some research.

I didn't get any help from anyone and I couldn't find a tutorial, but I got some idea to put the path after the servlet and use a servlet mapping in web.xml.

My idea was that I could then parse the location from the servlet to get the real page I wanted to go to. This would allow me to have doGet and doPost handle the page almost identically while using a RequestDispatcher.

It turns out that the servlet API already has such feature, so I was partially reinventing the wheel. The method is getPathInfo of HttpServletRequest.

I made a quick tutorial on it and put it on my website.

http://dhtmlkitchen.com/java/servlet/bookmarkable/

You'll be surprised how easy it is.


Garrett

Reply With Quote
  #5  
Old September 15th, 2002, 10:15 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
You can also use response.sendRedirect() in place of request.getRequestDispatcher().forward(). The disadvantage of this of course is that you can't send the request and response objects on, but you can still use sessions and the query string.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > URL updating from a servlet dispatcher


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway