Java Mail Problems within JSP Page
Hi all,
I'm encountering the following problem. I hava a jsp file named common.jsp with holds all common functions like write header and footer and also a send mail function. i include this page in all my other jsp pages. In the signup page - i need to send out 2 emails, one to the administrator and the other to the user who signed up. so i call that send mail function twice. the first call works(meaning it sends out the email) but the second call gives me a No SMTP Provider exception. Can anyone help me with this.
thx a bunch
p.s: i have included the sendEmail Function below
public void sendEmail(String emailServer, String sEmail, String sName, String rEmail,
String subject, String strmsg) throws Exception {
java.util.Properties props = new java.util.Properties();
props.put("mail.host", emailServer);
javax.mail.Session mailConn = javax.mail.Session.getInstance(props, null);
javax.mail.Message msg = new javax.mail.internet.MimeMessage(mailConn);
javax.mail.Address sender = new javax.mail.internet.InternetAddress(sEmail, sName);
javax.mail.Address receiver = new javax.mail.internet.InternetAddress(rEmail);
msg.setContent(strmsg,"text/html");
msg.setFrom(sender);
msg.setRecipient(javax.mail.Message.RecipientType.TO, receiver);
msg.setSubject(subject);
javax.mail.Transport.send(msg);
}
This is what i use and it works just fine
import java.io.*;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.*;
public class sendMail {
public sendMail(String To,String Subject,String message) {
String to = To, subject = Subject, from = null,
cc = null, bcc = null, url = null;
String protocol = null, host = null, user = null, password = null;
boolean debug = false;
try{
Properties props = System.getProperties();
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
if (debug)
session.setDebug(true);
msg.setFrom(new InternetAddress("[email protected]"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText(message);
msg.setHeader("Mail","test.com");
msg.setSentDate(new Date());
Transport.send(msg);
System.out.println("\nMail was sent successfully.");
} catch (Exception e) {
e.printStackTrace();
Similar Messages
-
How to Generate a Java file for a JSP Page
Hi ,
I am using weblogic11 .
I am working on a JSP page which nearly consists of 4000 lines of code.
I need to debug the file , but weblogic server is not generating the java file for the JSP pages .
Please let me know how can i genertae Java file for the jsp pages ??JSPs are compiled into servlets automatically and those classes are stored in WEB-INF/classes folder. Servlet engine handles servlets.
-
How i can make my own connection in java source of a jsp page
How i can make my own connection in java source of a jsp page (How to get connection from JNDI datasource address) ?
imagine that i have a rowset in a web page , now i want to do some operation using
plain JDBC , so i will need a connection object.
I tried to get one of my rowsets connection but it return null ?
what is best way to retrive a connection from JNDI datasource that we define for our project?
for example if i have
myRowSet.setDataSourceName("java:comp/env/jdbc/be");
in web page constructor
now i want a pure connection from the same datasource ? JNDI
Thank youIt is not hard to get your own connection from datasource.
in your case you need to do like the the following code.
i provide sample to show you how to catch the exception and create an statement .
Connection con =null;
try{
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/be");
con = ds.getConnection();
java.sql.Statement st =con.createStatement();
}catch(SQLException sqlex){
sqlex.printStackTrace();
sqlex.getNextException().printStackTrace();
catch(NamingException nex){
nex.printStackTrace();
hth
Masoud kalali -
Can EJB's be called from within JSP pages?
Hi,
(This is a general question, not necessarily related to OAS in any way...)
I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
Any help would be appreciated. Thanks!
David Christopher
[email protected]Hi,
Check the following code: http://www.jguru.com/jguru/faq/view.jsp?EID=5314 for ejb example.
-Ruchi
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Davidc:
Hi,
(This is a general question, not necessarily related to OAS in any way...)
I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
Any help would be appreciated. Thanks!
David Christopher
[email protected]<HR></BLOCKQUOTE>
null -
how to send an email from jsp page using java mail?like for submitting a form an email will be sent to the user email-id(the email-id is stored/match-ed in/from the database)???i m using tomcat 5.5 and netbeans 6.5.1...........so what should i do if dont want to use google smtp/pop3 port???
import java.io.*;
import java.net.InetAddress;
import java.util.Properties;
import java.util.Date;
import javax.mail.*;
import javax.mail.internet.*;
* Demo app that shows how to construct and send an RFC822
* (singlepart) message.
* XXX - allow more than one recipient on the command line
* @author Max Spivak
* @author Bill Shannon
public class msgsend {
public static void main(String[] argv) {
String to, subject = null, from = null,
cc = null, bcc = null, url = null;
String mailhost = null;
String mailer = "msgsend";
String file = null;
String protocol = null, host = null, user = null, password = null;
String record = null; // name of folder in which to record mail
boolean debug = false;
BufferedReader in =
new BufferedReader(new InputStreamReader(System.in));
int optind;
* Process command line arguments.
for (optind = 0; optind < argv.length; optind++) {
if (argv[optind].equals("-T")) {
protocol = argv[++optind];
} else if (argv[optind].equals("-H")) {
host = argv[++optind];
} else if (argv[optind].equals("-U")) {
user = argv[++optind];
} else if (argv[optind].equals("-P")) {
password = argv[++optind];
} else if (argv[optind].equals("-M")) {
mailhost = argv[++optind];
} else if (argv[optind].equals("-f")) {
record = argv[++optind];
} else if (argv[optind].equals("-a")) {
file = argv[++optind];
} else if (argv[optind].equals("-s")) {
subject = argv[++optind];
} else if (argv[optind].equals("-o")) { // originator
from = argv[++optind];
} else if (argv[optind].equals("-c")) {
cc = argv[++optind];
} else if (argv[optind].equals("-b")) {
bcc = argv[++optind];
} else if (argv[optind].equals("-L")) {
url = argv[++optind];
} else if (argv[optind].equals("-d")) {
debug = true;
} else if (argv[optind].equals("--")) {
optind++;
break;
} else if (argv[optind].startsWith("-")) {
System.out.println(
"Usage: msgsend [[-L store-url] | [-T prot] [-H host] [-U user] [-P passwd]]");
System.out.println(
"\t[-s subject] [-o from-address] [-c cc-addresses] [-b bcc-addresses]");
System.out.println(
"\t[-f record-mailbox] [-M transport-host] [-a attach-file] [-d] [address]");
System.exit(1);
} else {
break;
try {
* Prompt for To and Subject, if not specified.
if (optind < argv.length) {
// XXX - concatenate all remaining arguments
to = argv[optind];
System.out.println("To: " + to);
} else {
System.out.print("To: ");
System.out.flush();
to = in.readLine();
if (subject == null) {
System.out.print("Subject: ");
System.out.flush();
subject = in.readLine();
} else {
System.out.println("Subject: " + subject);
* Initialize the JavaMail Session.
Properties props = System.getProperties();
// XXX - could use Session.getTransport() and Transport.connect()
// XXX - assume we're using SMTP
if (mailhost != null)
props.put("mail.smtp.host", mailhost);
// Get a Session object
Session session = Session.getInstance(props, null);
if (debug)
session.setDebug(true);
* Construct the message and send it.
Message msg = new MimeMessage(session);
if (from != null)
msg.setFrom(new InternetAddress(from));
else
msg.setFrom();
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));
if (cc != null)
msg.setRecipients(Message.RecipientType.CC,
InternetAddress.parse(cc, false));
if (bcc != null)
msg.setRecipients(Message.RecipientType.BCC,
InternetAddress.parse(bcc, false));
msg.setSubject(subject);
String text = collect(in);
if (file != null) {
// Attach the specified file.
// We need a multipart message to hold the attachment.
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(text);
MimeBodyPart mbp2 = new MimeBodyPart();
mbp2.attachFile(file);
MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
} else {
// If the desired charset is known, you can use
// setText(text, charset)
msg.setText(text);
msg.setHeader("X-Mailer", mailer);
msg.setSentDate(new Date());
// send the thing off
Transport.send(msg);
System.out.println("\nMail was sent successfully.");
* Save a copy of the message, if requested.
if (record != null) {
// Get a Store object
Store store = null;
if (url != null) {
URLName urln = new URLName(url);
store = session.getStore(urln);
store.connect();
} else {
if (protocol != null)
store = session.getStore(protocol);
else
store = session.getStore();
// Connect
if (host != null || user != null || password != null)
store.connect(host, user, password);
else
store.connect();
// Get record Folder. Create if it does not exist.
Folder folder = store.getFolder(record);
if (folder == null) {
System.err.println("Can't get record folder.");
System.exit(1);
if (!folder.exists())
folder.create(Folder.HOLDS_MESSAGES);
Message[] msgs = new Message[1];
msgs[0] = msg;
folder.appendMessages(msgs);
System.out.println("Mail was recorded successfully.");
} catch (Exception e) {
e.printStackTrace();
* Read the body of the message until EOF.
public static String collect(BufferedReader in) throws IOException {
String line;
StringBuffer sb = new StringBuffer();
while ((line = in.readLine()) != null) {
sb.append(line);
sb.append("\n");
return sb.toString();
}now what should i do???to call it from jsp??? -
Java compilation and running within jsp page
hi,
i need of a jsp page that has a textarea in which the java coding are entered and this coding is compiled and executed. The execution result is printed.
Please guide me.I don't think you can invoke java compiler or run time environment at client side (browser). Even if you use applet, i think you will not be able to do it at client side. Moreover, though java virtual machine will be available in your target user's browser, but you should not expect a java compiler in users machine.
I have seen exam sites where they have added java code compilation and execution ability. To achieve this you can do:
1. In your JSP page use text area where user can edit java code.
2. Provide two buttons - 'Compile' and 'Run'.
3. On click of 'Compile' send the code to server side. In server machine create a file in a temporary location in disk and save the code content received from client.
4. Invoke 'javac' command (as a separate process) to compile the java class created in step 3. This process will give you error/output back which you can send back to user.
5. In case of 'Run' you must first invoke above mentioned 'Compile' service and then another service ('Run') to actually run you java class. You can build 'Run' service in similar way.
Here you challenge would be managing multiple client requests (to compile and run java class) at the same time.
Code to compile and run java classes:
import java.io.*;
* A class to compile and run java classes.
* @author Mrityunjoy Saha
public class JavaProcessor{
public static void main(String[] args){
// Option 1 to compile and option 2 to run.
int option=1;
if(args.length > 0){
option=Integer.parseInt(args[0]);
JavaProcessor p=new JavaProcessor();
if(option==1){
p.compile();
} else {
p.run();
public void run(){
String file="FoodTest";
String directory="C:/Users/mrityunjoy_saha/Documents/Test";
executeCommand("java", directory, file);
public void compile(){
String file="FoodTest.java";
String directory="C:/Users/mrityunjoy_saha/Documents/Test";
executeCommand("javac", directory, file);
public void executeCommand(String command, String directory, String file){
try{
String[] envp=null;
// Make sure that you have done Java setup in your machine.
// To test this try invoking javac command in command prompt.
Process p=Runtime.getRuntime().exec(command+" "+file,envp,new File(directory));
BufferedReader errorStream=new BufferedReader(new InputStreamReader(p.getErrorStream()));
String readData="";
while((readData=errorStream.readLine())!=null){
System.out.println(readData);
BufferedReader outStream=new BufferedReader(new InputStreamReader(p.getInputStream()));
readData="";
while((readData=outStream.readLine())!=null){
System.out.println(readData);
catch(IOException ioe){
ioe.printStackTrace();
}Thanks,
Mrityunjoy -
Opening a Java Window from a jsp page on the client side
Hi all,
Thanks in advance to all who could help me for this problem.
I've written some jsp pages. In one of them, I open a new Java Window,
which is a simple Java Frame. If I test this directly on the Tomcat
server, everything works well.
But when I call the jsp page through a web browser of a distant client
(normal use), and when I want to see the java window, no window pops
up. It appears that the Java Window pops up on the server, and not on
the client side, which is what I wanted.
Could someone tell me how to make the Java frames appear on the client
side ? (Is it linked to the code or to the configuration of Tomcat ?)
Thanks in advance,
Alexis.JSP always run on the server. On the client you only see the results.
But you can use applets on the client side: http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html -
Tomcat 6 Calling a Java Servlet from a JSP Page
Below is a very simple JSP Page that calls a Java Servlet. The question is given Tomcat security constraints, is it possible to call a servlet from a JSP and get the correct output without getting an error message? If so, how would you code the web.xml file?
c:\apache-tomcat-6.0.18
Under conf
catalina
localhost
HelloWorldExample.xml is directly under localhost
The application would have this directory structure:
webapps
HelloWorldExample
hello.jsp is directly under HelloWorldExample
Under HelloWorldExample
src
WEB-INF
classes
Under classes
jservlets
HelloWorld.java is in src folder
HelloWorld.class is in jservlets folder
HelloWorldExample.xml
<Context path="/HelloWorldExample" docBase="HelloWorldExample" debug="0"
reloadable="true" crossContext="true">
</Context>**************************
hello.jsp
<HTML>
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<FONT SIZE="4">
<P>
Please enter your name:
<FORM
METHOD="Post"
ACTION="servlet/jservlets.HelloWorld">
<TABLE BORDER="3" CELLPADDING="1" WIDTH="100%" ALIGN="CENTER">
<TR>
<TD><B>Name:</B></TD>
<TD><INPUT TYPE="text" NAME="Name" VALUE="" SIZE="65"> </TD>
</TR>
</TABLE>
<P>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</FONT>
</BODY>
</HTML>******************
HelloWorld.java
package jservlets;
import java.io.*;
import java.util.Date;
import java.util.*;
import java.text.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
PrintWriter out;
PrintWriter err;
String strName;
public void displayMessage(HttpServletRequest request, HttpServletResponse response)
throws Exception
try
if (!strName.equals("") && strName != null)
out.println("Hello " + strName + "" + "<P>");
out.println("Hello World" + "<P>");
else
out.println("Hello World" + "<P>");
catch (Exception e)
out.println("Exception: Could not display message." + "<P>");
err.println (e.getMessage () ) ;
out.println("<P>");
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
try
response.setContentType("text/html");
out = response.getWriter();
err = response.getWriter();
strName = request.getParameter("Name").trim();
out.println("<html><head><title>");
out.println("</title></head><body>");
out.println("<FORM");
out.println("METHOD=POST");
out.println("ACTION=http://localhost:8080/HelloWorldExample/hello.jsp>");
out.println("<TABLE ALIGN='RIGHT'>");
out.println("<TR>");
out.println("<TD>");
out.println("<INPUT TYPE=\"SUBMIT\" VALUE=\"Hello World Page\";>");
out.println("</INPUT>");
out.println("</TD>");
out.println("</TR>");
out.println("</TABLE>");
out.println("</FORM>");
out.println("<BR CLEAR='all'>");
out.println("<P>");
displayMessage(request, response);
out.close();
out.println("</body></html>");
catch(Throwable e)
e.printStackTrace();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
doPost(request, response);
web.xml
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>jservlets.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping> ******************************
HelloWorld.java can be compiled by using javac.
Once compiled, HelloWorld.class would be moved to the jservlets folder.
FYI, coding the above url-pattern results in:
HTTP Status 404
The requested resource (/HelloWorldExample/servlet/jservlets.HelloWorld) is not available
The following url-pattern in the web.xml file permits the servlet to be executed but results in a null pointer exception:
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/ </url-pattern>
</servlet-mapping> **************************************************
RobinThis problem was resolved.
In hello.jsp
ACTION="servlet/jservlets.HelloWorld">
was replaced with
ACTION="servlet/HelloWorld">
Robin -
Java.lang.ClassCastException in JSP page
My JSP page:
<%@page contentType="text/html"%>
<HTML>
<HEAD>
<TITLE> JDBC Servlet/JSP Example </TITLE>
</HEAD>
<BODY>
<%@ page import="myBeans.memoryBean" %>
<%@ page import="java.util.Vector" %>
<H1> JDBC Servlet/JSP Example </H1>
<H2> <%= session.getValue("message") %>
</H2>
<UL>
<%
Vector vData = (Vector) session.getValue("res");
myBeans.memoryBean mb;
Object o;
for (Enumeration e = vData.elements() ; e.hasMoreElements() ;) {
o = e.nextElement();
mb = (myBeans.memoryBean) o;
%>
<LI> <%= o.getClass().getName() %>
<% } // end for
%>
</UL>
</BODY>
</HTML>Notice that I don't even use the object I cast but I still get the error message:
Exception:
java.lang.ClassCastException
at _memory._search._jspService(_search.java:66)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java)
at oracle.jsp.JspServlet.internalService(JspServlet.java)
at oracle.jsp.JspServlet.service(JspServlet.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:534)When I comment out the line that castes my object my browser displays:
JDBC Servlet/JSP Example
Records Found:
* myBeans.memoryBean
* myBeans.memoryBean
* myBeans.memoryBean Notice that the three objects that are returned are exactly the type that I caste to.
Also, I did a getClass().getClassLoader() when I create the objects in my servlet code and again on the JSP pages for each object I pull out of the vector and the class loader matched.
I even changed the package on my bean class and recompiled everything to make sure it wasn't a old .class file floating around.
Could this have something to do with my classpath or where my classes are being placed? I found a similar problem here: http://forum.java.sun.com/thread.jsp?forum=33&thread=380437&start=0&range=15&hilite=false&q=
but the explanation of what was done wasn't clear
Anyone have any idea what's going on here?
I am using:
Oracle 9i
Oracle HTTP Server Powered by Apache/1.3.12 (Unix)
ApacheJServ/1.1
Thanks in advance.
- LinusIs ti at all possible that you have another jar / zip file with the same class file in it, seemingly away from the Server classpath ? In which case this could happen even though logically it shouldn't !!!
-
Problem in Jsp page it doesnt shows users from database
hi dear all...
in my project i am creating new user by user registration(filling all details UserId,Passwd,retypepwd,name,emailid,dob,mob.no.,images-browse) so it will stored in my backend database oracle which is shown by using sql commands i.e.select * from userdetails until its ok BUT I FACE PROBLEM WHEN I CLICK VIEWUSERS IN MY JSP PAGE IT DOESNOT SHOW THE USERS...IN ECLIPSE10 I GOT ERRRO AS BELOW..
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.BeanUtils).
log4j:WARN Please initialize the log4j system properly.
in registerDAO connection is .oracle.jdbc.driver.T4CConnection@15c998a
in dao dob5-Mar-2013
qqqloginid
photo=C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg
fole=105542
java.lang.NullPointerException
at com.multistep.action.RegisterAction.doPost(RegisterAction.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
ANY HELP APPRICIATED.....
-AVINASHYou should format that date. See SimpleDateFormat in Java API.
-
Loading Java Class File in JSP page
I'm trying to load a java class file from a jsp page.
(e.g. MyFile.java <-- Source "MyFile.class<--Class file of MyFile.java")
jsp page
<%@ include file = "MyFile.class" %>
<HTML> // HTML Tags are here
MyFile.java
A normal java source file that has "public static void main" in it.
My jsp page can display it's contents, 'except' for showing e.g. "1235%%215648%%public%%$$@##" through out the page...
My guess is that it can't display my java class file..
Can anyone please help me solve this problem of mine ?
Thanks in advance : )
Yours Sincerely,
RainbowEnergiesThis is my JSP file.
<HTML>
<HEAD>
<TITLE>Activity Games</TITLE>
</HEAD>
<%
String name = "";
String id = "";
name = session.getAttribute("name").toString();
session.setAttribute("name",name);
id = session.getAttribute("id").toString();
session.setAttribute("id",id);
%>
<BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
<H3><%=name%>, you have enter Activity Games</H3>
<%@ page import="Games.Lufia.*" %>
<%Lufia lufia = new Lufia();%>
</BODY>
</HTML>
After I execute...
An error occurred at line: 18 in the jsp file: /jsp/ActivityGames.jsp
error: File C:\Program Files\Apache Tomcat 4.0\webapps\website\WEB-INF\classes\Games\Lufia\Lufia.class does not contain type Games.Lufia.Lufia as expected, but type Lufia. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\website\jsp\ActivityGames$jsp.java:85: Class Games.Lufia.Lufia not found.
Lufia lufia = new Lufia();
But if I comment this out....
This is my JSP file.
<HTML>
<HEAD>
<TITLE>Activity Games</TITLE>
</HEAD>
<%
String name = "";
String id = "";
name = session.getAttribute("name").toString();
session.setAttribute("name",name);
id = session.getAttribute("id").toString();
session.setAttribute("id",id);
%>
<BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
<H3><%=name%>, you have enter Activity Games</H3>
<%@ page import="Games.Lufia.*" %>
<%//Lufia lufia = new Lufia();%> <--- comment this out.... (HERE)
</BODY>
</HTML>
The page shows but did not run my java class file..
Thanks again for trying to help me solve this problem of mine. : - )
Regards,
RainbowEnergies -
Recompilation of java class invalidates taglib jsp page?
Hi everyone,
I have a JSP page which calls a custom tag library. On freshly compiling
everything and
calling the JSP page from a browser for the first time the output is as
expected.
However when ever I recompile one of the classes that get called anywhere in
the tag
library call the tag no longer works (internal error from the server).
To get it to work I have to change the jsp page so that it recompiles.
Weblogic server 5.1 (no service patches yet) running on NT server SP6a.
Any ideas?
MTIA
Craig
p.s
The following errors are in the log file.
Is this another class casting problem?
Does any one have any explanations?
Ta
Craig
<ServletContext-General> Servlet failed with Exception
javax.servlet.ServletException: runtime failure in custom tag 'MyTag'
at jsp_servlet._taglib._jspService(_taglib.java:89)
at weblogic.servlet.jsp.JspBase.service(JspBase.java, Compiled Code)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
, Compiled Code)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java, Compiled Code)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java, Compiled Code)
at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
Manager.java, Compiled Code)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,
Compiled Code)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
Compiled Code)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
<ServletContext-General> root cause of ServletException
java.lang.ClassCastException: com.bt.db.MyTag
at jsp_servlet._taglib._jspService(_taglib.java:77)
at weblogic.servlet.jsp.JspBase.service(JspBase.java, Compiled Code)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
, Compiled Code)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java, Compiled Code)
at
weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
l.java, Compiled Code)
at
weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
Manager.java, Compiled Code)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,
Compiled Code)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
Compiled Code)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
"crg" <[email protected]> wrote in message
news:[email protected]...
> Hi everyone,
>
> I have a JSP page which calls a custom tag library. On freshly compiling
> everything and
> calling the JSP page from a browser for the first time the output is as
> expected.
> However when ever I recompile one of the classes that get called anywhere
in
> the tag
> library call the tag no longer works (internal error from the server).
> To get it to work I have to change the jsp page so that it recompiles.
>
> Weblogic server 5.1 (no service patches yet) running on NT server SP6a.
>
> Any ideas?
> MTIA
>
> Craig
>
>
>
>
-
Java script problem in JSP called thru servlet
when jsp page is displayed thru a servlet in following way the java scripts built in that JSP page are not working.
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.include(req, res);
how can i enable these java scripts?Most probably you have something like this:
<script language="JavaScript1.2" src="menu.js"></script>
The bit that is probably causing the problem is the src attribute.
Its a common issue when using the request dispatcher
You request "/servlets/myServlet"
it forwards to "/jsp/myJSP"
You try and access a resource using a relative URL.
however, the browser knows nothing about the forward being done - it thinks that the URL is /servlets/myServlet, when you want it to be /jsp/myJSP.jsp
So if you access menu.js it will look in /servlets/menu.js instead of /jsp/menu.js (example only)
to fix
1 - Don't use relative links. Ie use /scripts/menu.js to import the script
2 - use a <base> tag <base href="http://www.mywebsite.com/jsp/> This tells a web page where to resolve relative references from.
Hope this helps,
evnafets -
EL problem in JSP page, boolean vs. String
We are migrating from WebSphere 6 to WebLogic 11g and are receiving the following error from the JSP pages where we use EL to determine if an element is readonly or not:
The method setReadonly(boolean) in the type BaseHandlerTag is not applicable for the arguments (String)
In doing some testing I can simplify the problem to this:
works (just using EL to set tab index)
jsp:
<c:set var="myTabIndex" value="765" />
<html:text property="user.email" size="28" tabindex="${myTabIndex}" readonly="true" />
source output:
<input type="text" name="user.email" size="28" tabindex="765" value="[email protected]" readonly="readonly">
doesn't work (added EL to set readonly attribute)
jsp:
<c:set var="myTabIndex" value="765" />
<c:set var="myReadOnly" value="true" />
<html:text property="user.email" size="28" tabindex="${myTabIndex}" readonly="${myReadOnly}" />
error output:
userProfile.jsp:60:86: The method setReadonly(boolean) in the type BaseHandlerTag is not applicable for the arguments (String)
<html:text property="user.email" size="28" tabindex="${myTabIndex}" readonly="${myReadOnly}" />
I'm not sure what is going on here and have spent two days researching this and trying different things to no avail. I don't believe any casting should be necessary. I thought for a while EL was not enabled but in my working sample EL is being used to determine tab index. The 'does not work' code works ok in WebSphere 6 and Tomcat 6, so it is just WebLogic we are having an issue with.
Thanks in advance for any help that can be provided.
MichaelFound more output in the log file that might be helpful (this is output from the real code, not the sample code I mentioned previously):
weblogic.servlet.jsp.CompilationException: Failed to compile JSP /WEB-INF/modules/ContactTile.jsp
ContactTile.jsp:241:17: The method setReadonly(boolean) in the type BaseHandlerTag is not applicable for the arguments (String)
readonly="${displayonly}"
^--------------^
at weblogic.servlet.jsp.JavelinxJSPStub.reportCompilationErrorIfNeccessary(JavelinxJSPStub.java:226)
at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:162)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:256)
at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:216)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
Truncated. see log file for complete stacktrace
Michael -
Problems with JSP-Pages in more than 1 Frame
I have 4 Frames on my Page and every Frame is a JSP-Page. Every Page has different Data Tags, different View Objects etc.
I could run each of the 4 Pages without getting an error-message, but after starting the Frameset-Page, I get the Error-Message:
Error Message: JBO-27022: Failed to load value at index 1 with java object of type
java.lang.String due to java.sql.SQLException.
Now I press the Reload-Button of my Browser and it works !!!
Could anyone help me ?Um, what am I missing? What is the work around? Is it impossible to use frames and data tag JSPs? Heino, how did you get around this problem?
Do I have to create separate App Modules for each frame (yuck)
Thanks!
Maybe you are looking for
-
Hi, I'm trying to load data it is given an error, WRT_8025 Error in BW Target. [Number of fields in Target do not Match Repository fields = 15 BW fields = 18] WRITER_1_*_1> Wed Oct 19 15:07:55 2007 WRITER_1_*_1> WRT_8025 Error in BW Target. [===> Com
-
How can I disable my MobileMe account as sender in the iOS Mail app?
Ever since I logged on to iCloud in OS X Mountain Lion (10.8.0, 10.8.1), I've noticed that in Gmail (using the Mail app for iOS), on my iPhone running iOS 5.1.1, the sender appears to be my MobileMe account (an account I had to use a while back when
-
Problem in creating database -Missing Redo log file
I am try to create a new database using DBCA .While creating a database it shows the error oracle instance terminated.Force Disconnected. My alert log file is Errors in file /u01/app/oracle/diag/rdbms/oracl/oracl/trace/oracl_ora_5424.trc: ORA-00313:
-
I am using Adobe Acrobat Reader 9.4.5 (tried X but was too slow). Here are some issues, in case anyone from development team is looking for improvement options. If there is solutions for any of this already, I am interested to learn more about it. 1.
-
Where to search for a specific Dimention related data
Hi, I guess, hyperion planning store the dimention related data( parent, child, uda,attributes, consolidation operator, data storage etc) in some relational tables of that planning application. Can anybody help me understand where & how those data is