Applet in JSP

Hi All,

can anyone help me to solve my problem.....

My problem is

"I m trying to create one web application in jsp.

and when i click button in this(JSP) page some value should be pass to Applet page like (2,2) and after perform some mathemetical operation on Applet page it shows result on JSp page".

i m not able to solve this problem tht how it possible.

So plz help me to solve this problem.

Thanks in advance..

[463 byte] By [javarocktheworlda] at [2007-11-27 7:39:16]
# 1
you didn't tell us what's exactly your problem ?!!anyway, you'll find here many examples of applet-javascript(or java-html) interaction : http://64.18.163.122/rgagnon/topics/java-js.htmlHope That Helps
java_2006a at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

[nobr]alright below is a typical example for you hopw that might give you some idea.

First.JSP:

========

<%@ page language="java"%>

<html>

<head>

<title>Add Numbers</title>

</head>

<body>

<form action="Second.jsp">

Number 1:<input type="text" name="no1">

<br/>

Number 2:<input type="text" name="no2">

<br/>

<input type="submit" name="submit" value="add">

</form>

</body>

</html>

Second.jsp:

==========

<%@ page language="java"%>

<%@ page include="./First.jsp"%>

<center>

<jsp:plugin type="applet" class="SampleApplet.class" align="bottom" height="100" width="100">

<jsp:params>

<jsp:param name="no1" value="<%=request.getParameter("no1")%>"/>

<jsp:param name="no2" value="<%=request.getParameter("no2")%>"/>

</jsp:params>

<jsp:fallback>

Unable to load applet

</jsp:fallback>

</jsp:plugin>

</center>

SampleApplet.java:

===============

import java.awt.Graphics;

import javax.swing.JApplet;

public class SampleApplet extends JApplet{

private int num1 = 0;

private int num2 = 0;

public void init() {

try{

num1 = Integer.parseInt(this.getParameter("no1"));

num2 = Integer.parseInt(this.getParameter("no2"));

}catch(Exception exp){

}

}

public void paint(Graphics g){

super.paint(g);

g.drawString("Value is :"+(num1+num2),25,25);

}

}

Hope this might help :)

REGARDS,

RaHuL[/nobr]

RahulSharnaa at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

bt this gives some Exception like

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /Anjan/Second.jsp(2,0) Page directive has invalid attribute: include

org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)

org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)

org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)

org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:348)

org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:144)

org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:578)

org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2176)

org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2226)

org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2232)

org.apache.jasper.compiler.Node$Root.accept(Node.java:485)

org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2176)

org.apache.jasper.compiler.Validator.validate(Validator.java:1478)

org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:253)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:459)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

note The full stack trace of the root cause is available in the Tomcat logs.

why this gives this Exception?

javarocktheworlda at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
i'm sorry that was a small sematic mistake...use <%@ include file="..\First.jsp" %>instead of <%@ page include="..\First.jsp" %>
RahulSharnaa at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Now it show this Error.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /Anjan/an/Second.jsp(6,0) Plugin: Mandatory attribute code missing

org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:83)

org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:402)

org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)

org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:327)

org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:567)

org.apache.jasper.compiler.Node$PlugIn.accept(Node.java:1165)

org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2176)

org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2226)

org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2232)

org.apache.jasper.compiler.Node$Root.accept(Node.java:485)

org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2176)

org.apache.jasper.compiler.Validator.validate(Validator.java:1515)

org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:253)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:459)

org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)

org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)

javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

note The full stack trace of the root cause is available in the Tomcat logs.

thanks in advance.

javarocktheworlda at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

<%@ page language="java"%>

<%@ include file="./First.jsp"%>

<center>

<jsp:plugin type="applet" code="SampleApplet.class" align="bottom" height="100" width="100">

<jsp:params>

<jsp:param name="no1" value="<%=request.getParameter("no1")%>"/>

<jsp:param name="no2" value="<%=request.getParameter("no2")%>"/>

</jsp:params>

<jsp:fallback>

Unable to load applet

</jsp:fallback>

</jsp:plugin>

</center>

RahulSharnaa at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
thnks now its working.....thanks again..
javarocktheworlda at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
alright how about dukes stars then you can distribute it between ppl if you feel others have helped you on this.
RahulSharnaa at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
i dont know abt funda of duke star...really i m new to this forum.....plz let me know ........
javarocktheworlda at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10
http://developers.sun.com/forums/dukestars/index.jsp
RahulSharnaa at 2007-7-12 19:19:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...