Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt in servlets  RSS feed

 
sreeramulu b
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
I want to display applet in servlet. Please try to send me relative code of it.

Thanks in advance
Sreeramulu
 
chetan nain
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this.......
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class AppletInServlet extends HttpServlet
{
String code="AppletToServlet.class";
public void init(ServletConfig config) throws ServletException
{
System.out.println("Servlet entered");
super.init();
}


public void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
{
PrintWriter out=response.getWriter();
out.println("<html><body><applet code=\""+code+"\" codebase=\"/\" width=200 height=200></applet></body></html>");
}
}
note that i have place the AppletToServlet.class file in my servlets directory in JWS2.0 . if that is not to be done, you may need to alter your codebase path.
hope this helps
regds
chetan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!