• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt in servlets  RSS feed

 
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
 
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
 
permaculture is largely about replacing oil with people. And one tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!