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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old February 28th, 2001, 09:35 AM
Violaine Violaine is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: FRANCE
Posts: 0 Violaine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question

I have 2 questions.
First how can I call a servlet from a frame?
Second, how can I passed data from a servlet to a jsp?
Thanks in advance.

Reply With Quote
  #2  
Old February 28th, 2001, 11:12 AM
wolfespawn wolfespawn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 68 wolfespawn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via AIM to wolfespawn
as for the jsp part, I will be learning that in a couple of weeks when I get some projects done. To call a servlet from html frame, you just call the class file.

<FRAME SRC="/servlets/My_Servlet" NAME="body" NORESIZE
frameborder="YES" scrolling="YES" bordercolor="#999999">

Usually this is all inside frameset tags or whatever.
I hope this is what you were asking...


Reply With Quote
  #3  
Old February 28th, 2001, 05:14 PM
hoi hoi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Location: NY
Posts: 0 hoi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to hoi
Thumbs up add it into request object...

hi there,

you can add your objects into the HttpServletRequest object
and then redirect from your servlet to the jsp page.

e.g. from "AServlet.java", passing a String object to the "a.jsp" file.

In "AServlet.java":
....
...doGet(HttpServletRequeet req, HttpServletResponse res)
{
// the jsp file i wanna redirect to
String target = "a.jsp";

// creating a String object
String hello = "Hello people!";

// add it into the HttpServletRequest object
req.setAttribute("hello", hello);

// create a dispatch from the ServletContext object
// to do the redirection for me =)
// don't forget to specify where you wanna go.
RequestDispatcher rd = getServletContext().getRequestDispatcher(target);

// now here is the magic... you are passing the
// HttpServletRequest obj and HttpServletResponse obj
// to the jsp page
rd.forward(req, res);

.....
// code here will not be execute since you have
// pass the control to "a.jsp"
}
....


In the "a.jsp" page, you can retrieve the "hello" object
by doing this:
<%
String hello = (String)request.getAttribute("hello");
out.println(hello);
%>

It's very helpful by doing this because you can hide
all the business logic inside the Servlet and the JSP
file will just be doing printing...

hope it help.
-hoi =)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Servlet and jsp


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 | 
  
 





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