servlet question
Hi, I try to forward a HTTP request from my servlet. I am using the following code. RequestDispatcher rd = getServletContext().getRequestDispatcher(direct); rd.forward(request, response); I have no problem with code, but I have one issue is how can I change the request method from POST to GET before I forward the original request. I would appreciate any help Paul
Re: servlet question
Thank you for the help. I think you may misunderstand my question. My question is how can I forward the request to my next URL and change the method to 'GET' if the orignal request is using 'POST'. For example: test1.html call servlet1 by using POST method, but servlet1 need to forward to servlet2 by using GET. How can I switch from POST to GET in servlet1. thanks - Original Message - From: Jose Euclides da Silva Junior - DATAPREVRJ [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:26 PM Subject: RES: servlet question try doGet() instead of doPost(). good luck. -Mensagem original- De: Paul Hsu [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 27 de maio de 2003 19:27 Para: [EMAIL PROTECTED] Assunto: servlet question Hi, I try to forward a HTTP request from my servlet. I am using the following code. RequestDispatcher rd = getServletContext().getRequestDispatcher(direct); rd.forward(request, response); I have no problem with code, but I have one issue is how can I change the request method from POST to GET before I forward the original request. I would appreciate any help Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: servlet question
Actually my servlet try to forward a 'POST' request to a Flash program, but the Flash program cannot process 'POST', so I must forward the request to Flash with 'GET' method. That is my issue. - Original Message - From: Hassan [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:45 PM Subject: Re: servlet question if your dispatched request is getting problems because of non compatible types of GET/Post methods at collaborating servlets then at the receiving end add a dummy method of (Get or Post), whichever is missing, and forward the processing to the actual method. For example: protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { doPost(req, res); } protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { with full implementation } - Original Message - From: Paul Hsu [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 11:26 PM Subject: servlet question Hi, I try to forward a HTTP request from my servlet. I am using the following code. RequestDispatcher rd = getServletContext().getRequestDispatcher(direct); rd.forward(request, response); I have no problem with code, but I have one issue is how can I change the request method from POST to GET before I forward the original request. I would appreciate any help Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: servlet question
My code is doing this way already, but it does not work.You think the method will change if I forward the POST request inside doGet(). - Original Message - From: Tam, Michael [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:44 PM Subject: RE: servlet question Just a wild guess, how about servlet 1 doPost() call its own doGet() and redirect in the doGet body??? -Original Message- From: Paul Hsu [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:41 PM To: Tomcat Users List Subject: Re: servlet question Thank you for the help. I think you may misunderstand my question. My question is how can I forward the request to my next URL and change the method to 'GET' if the orignal request is using 'POST'. For example: test1.html call servlet1 by using POST method, but servlet1 need to forward to servlet2 by using GET. How can I switch from POST to GET in servlet1. thanks - Original Message - From: Jose Euclides da Silva Junior - DATAPREVRJ [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:26 PM Subject: RES: servlet question try doGet() instead of doPost(). good luck. -Mensagem original- De: Paul Hsu [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 27 de maio de 2003 19:27 Para: [EMAIL PROTECTED] Assunto: servlet question Hi, I try to forward a HTTP request from my servlet. I am using the following code. RequestDispatcher rd = getServletContext().getRequestDispatcher(direct); rd.forward(request, response); I have no problem with code, but I have one issue is how can I change the request method from POST to GET before I forward the original request. I would appreciate any help Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: servlet question
Michael, If I forward to a servlet, yes I can process the request in second servlet. - Original Message - From: Tam, Michael [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 4:13 PM Subject: RE: servlet question I am not possitive. I am not familiar with flash but can you process your post data in servlet 1 and form an url with parameters attached and then redirect? -Original Message- From: Paul Hsu [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:58 PM To: Tomcat Users List Subject: Re: servlet question My code is doing this way already, but it does not work.You think the method will change if I forward the POST request inside doGet(). - Original Message - From: Tam, Michael [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:44 PM Subject: RE: servlet question Just a wild guess, how about servlet 1 doPost() call its own doGet() and redirect in the doGet body??? -Original Message- From: Paul Hsu [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:41 PM To: Tomcat Users List Subject: Re: servlet question Thank you for the help. I think you may misunderstand my question. My question is how can I forward the request to my next URL and change the method to 'GET' if the orignal request is using 'POST'. For example: test1.html call servlet1 by using POST method, but servlet1 need to forward to servlet2 by using GET. How can I switch from POST to GET in servlet1. thanks - Original Message - From: Jose Euclides da Silva Junior - DATAPREVRJ [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, May 27, 2003 3:26 PM Subject: RES: servlet question try doGet() instead of doPost(). good luck. -Mensagem original- De: Paul Hsu [mailto:[EMAIL PROTECTED] Enviada em: terça-feira, 27 de maio de 2003 19:27 Para: [EMAIL PROTECTED] Assunto: servlet question Hi, I try to forward a HTTP request from my servlet. I am using the following code. RequestDispatcher rd = getServletContext().getRequestDispatcher(direct); rd.forward(request, response); I have no problem with code, but I have one issue is how can I change the request method from POST to GET before I forward the original request. I would appreciate any help Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
help on mod_jk
Hi, I try to install mod_jk with apache, but I always have problem with jk_mod. I install tomcat-4.0.6 and download mod_jk2-1.3-eapi.so into modules directory. Then I append one line LoadModule jk_module modules/mod_jk2-1.3-eapi.so at the end of httpd.conf file, I run apachectl configtest, I got the following error. I am really puzzled how this work. Any help will be appreciated. [root]# ./apachectl configtest Syntax error on line 1070 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/mod_jk2-1.3-eapi.so into server: /usr/loc al/apache2/modules/mod_jk2-1.3-eapi.so: undefined symbol: ap_table_get thanks Paul
Re: shared resources
Todd, You need to put your jar file under $CATALINA_HOME/common direcotry. $CATALINA_HOME/shared directory are only available to Catalina engine, not application but /common can be seen by both engine and application. Paul - Original Message - From: Pat McGroin [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, March 30, 2003 5:32 PM Subject: Re: shared resources Craig, Thanks again for the information. The info. you've supplied has been very useful. However, my problem remains: I cannot access the class that resides in a JAR file (utilities.jar) in tomcat_home/shared/lib and get a java.lang.NoClassDefFoundError I am spinning my wheels on this so hopefully some details will shed some light on my problem. I wrote a very simple servlet that attempts to use the class in the shared dir. import com.myco.utilities.CASDate; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Test1 extends HttpServlet { // public void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { System.out.println(GET method of Test1 invloked); performTask(request, response); } // public void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { System.out.println(POST method of Test1 invloked); performTask(request, response); } /** * Test the use of a shared class. */ public void performTask(HttpServletRequest request, HttpServletResponse response) { try { java.io.PrintWriter pw = response.getWriter(); CASDate today = new CASDate(); pw.println(CASDate today is + today.toString()); pw.println(CASDate class loaded...); } catch(Throwable theException) { System.out.println(Error...); theException.printStackTrace(System.out); } } } This is the utility class (some getXXX methods deleted for brevity): package com.myco.utilities; import java.util.Calendar; import java.util.GregorianCalendar; public class CASDate { private int ccc = 0; private int yyy = 0; private int mmm = 0; private int ddd = 0; private int time = 0; /** * Default constructor is to create CAS date using the current date. */ public CASDate() { super(); GregorianCalendar cal = new GregorianCalendar(); ccc = 20; yyy = cal.get(Calendar.YEAR) - 2000; mmm = cal.get(Calendar.MONTH) + 1; ddd = cal.get(Calendar.DAY_OF_MONTH); } /** * Return a string in MM/DD/CCYY format. */ public String toString() { String returnValue = getMonth() + / + getDay() + / + getYearAndCentury(); return returnValue; } } The error I get is: java.lang.NoClassDefFoundError: com/myco/utilities/CASDate When I moved utilities.jar to webapp/WEB-INF/lib the error goes away. I hope this provides some clues as to what is going wrong. At this point it looks like a bug but I hope I'm wrong. I am using Tomcat 4.1.18. Any help is GREATLY appreciated. Thanks, Todd -Original Message- From: Craig R. McClanahan[EMAIL PROTECTED] To: Pat McGroin[EMAIL PROTECTED] Date: Thu Mar 27 13:53:24 PST 2003 Subject: Re: shared resources On Thu, 27 Mar 2003, Pat McGroin wrote: Date: Thu, 27 Mar 2003 12:57:03 -0800 (PST) From: Pat McGroin [EMAIL PROTECTED] To: Craig R. McClanahan [EMAIL PROTECTED] Subject: Re: Re: shared resources Craig, Thanks very much for the detailed reply. That is very useful information for getting at resource files. However, my problem is much simpler. I am simply getting java.lang.NoClassDefFoundError errors when I try to use classes in JAR files in the tomcat_home/shared/lib directory. When I move the jar files to my webapp root/WEB-INF/lib the classes are loaded just fine and I don't see these errors. One likely cause for this sort of thing: if a class in your problem child JAR file is itself loaded from the shared class loader, but tries to access a different class that is in the webapp class loader, you'll get exactly this sort of problem. Note that NoClassDefFound errors do *not* say that the class named in the exception report cannot be found (that would be a ClassNotFoundException). Instead, it means that one of the classes that this class depends on cannot be found. Thanks, Todd Craig -Original Message- From: Craig R. McClanahan[EMAIL PROTECTED] To: Tomcat Users List[EMAIL PROTECTED] Date: Thu Mar 27 12:33:57 PST 2003 Subject: Re: shared resources On Thu, 27 Mar 2003, Pat McGroin wrote: Date: Thu, 27 Mar 2003 11:20:49 -0800 (PST) From: Pat McGroin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: shared resources Hello. I am trying to reference a few JAR files from an out-of-process Tomcat 4.1.18 application. The Tomcat 4.1 documentation says that unpacked shared classes
Question about mod_jk
Hi, I try to set up mod_jk on Apache 2.0.44 on window 2000. I download mod_jk.dll and save into modules/ directory. Then I put one line in httpd.conf file as following: LoadModule jk_module modules/mod_jk.dll then I use test configuration to test my setting. I always receive the message Cannot load C:/apache/apache2/modules/mod_jk.dll into server: the specified module cannot be found. I wonder the mod_jk.dll is the right file. Thanks in advance if any one can help me. Paul
question
Hi, I know tomcat already provide web server capability, under what knid circustance you need to intergrate apache with tomcat. My thinking is when you want to set up virtual host. I don't know this answer is correct? If any one can give me advice, thank you in advance. Paul
Re: question
Reynir, Thank you for your advice. So the main reason to intergrate with Apache is using Apache to ease the load from Tomcat. In other word, every static content will be rendered by Apache without Tomcat. If a web application use dynamic content mechanism such as JSP/Servlet, then the integration won't benifit us at all. Am I correct. I know some one use Apache for traffic load balance only. thanks Paul - Original Message - From: Reynir Hübner [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Sunday, March 09, 2003 8:59 AM Subject: RE: question You can set up virtual hosts with tomcat. You should set up another HTTP server (such as apache, IIS) if you want to use apaches capabilities and performance. Obviously having tomcat delivering static documents, such as images and .html can be a waste of resource. Performance is the biggest single reason to intergrate with apache. This dependes on the type of application you are using, and how big part of it is static content rather than dynamic content such as servlets/jsp. Then of course know-how of the people that will be running the system long term is very often a reason enough to deploy with either apache or IIS, as they don't neccesarily know how to configure tomcats security, but know how to do it in IIS/apache. Hope it helps, -reynir -Original Message- From: Paul Hsu [mailto:[EMAIL PROTECTED] Sent: 9. mars 2003 16:53 To: Tomcat Users List Subject: question Hi, I know tomcat already provide web server capability, under what knid circustance you need to intergrate apache with tomcat. My thinking is when you want to set up virtual host. I don't know this answer is correct? If any one can give me advice, thank you in advance. Paul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Java mail
Hi, I try to develope a java mail. I have a problem about how to authenticate email sender against email server. Since the email server ask for authentication if you want to send a email through that server because of spam issue. I got javax.mail.MessagingException==553 Authentication is required to send mail as [EMAIL PROTECTED] error every time. The following is my Mailer class. I wonder if any one know what is wrong with my code. Any help will be appreciated. package com.smartequip.email; import javax.mail.*; import javax.mail.internet.*; import javax.activation.FileDataSource; import javax.activation.DataHandler; import java.util.*; import java.io.*; import com.smartequip.common.AppBase; public class Mailer extends AppBase { public static String TEXTPLAIN = 1; public static String TEXTHTML = 2; public static String EDI = 3; private String smtpHost=null; private String subject=null; private String from=null; private Vector toV = new Vector(); private Vector ccV = new Vector(); private Vector attachedV = new Vector(); private String textMessage=null; private String message_type = 1; private String userName=; private String password=; private Auth auth; private Session session; public Mailer() { } public Mailer(String smtpHost) { this.smtpHost = smtpHost; } public void setUserName(String s) { this.userName = s; } public void setPassword(String s) { this.password = s; } public void setSmtpHost(String smtpHost) { this.smtpHost = smtpHost; } public void setFrom(String from) { this.from = from; } public void addTo(String to) { toV.add(to); } public void addCc(String cc) { ccV.add(cc); } public void setSubject(String subject) { this.subject = subject; } public void addAttached(String attached) { attachedV.add(attached); } public void setTextMessage(String message) { this.textMessage = message; } public void setMessageType(String t) { this.message_type = t; } public void send() throws Exception { Message msg = prepareHeader(); if(message_type.equals(TEXTPLAIN)) msg.setContent(textMessage, text/plain); if(message_type.equals(TEXTHTML)) msg.setContent(textMessage, text/html); sendMesg(msg); } private void sendMesg(Message msg) throws Exception { msg.saveChanges(); // implicit with send() Transport transport = session.getTransport(smtp); transport.connect(smtpHost, userName, password); transport.sendMessage(msg, msg.getAllRecipients()); transport.close(); } private Message prepareHeader() throws Exception { Properties props = new Properties(); if(smtpHost == null) throw new Exception(No SMTP Host specified.); props.put(mail.smtp.host, smtpHost); props.put(mail.user, userName); props.put(password, password); session = Session.getDefaultInstance(props, null); session.setDebug(true); Message msg = new MimeMessage(session); // set from if(from == null) throw new Exception(No Sender specified.); InternetAddress addr = new InternetAddress(from); msg.setFrom(addr); // set to if(toV.size() == 0) throw new Exception(No Recipients specified.); for (int i = 0; i toV.size(); i++) { InternetAddress addrt = new InternetAddress((String)toV.get(i)); msg.addRecipient(Message.RecipientType.TO, addrt); } // set cc for (int i = 0; i ccV.size(); i++) { InternetAddress addrt = new InternetAddress((String)ccV.get(i)); msg.addRecipient(Message.RecipientType.CC, addrt); } // set subject if(subject == null) throw new Exception(No Subject specified.); msg.setSubject(subject); msg.setSentDate(new Date()); return msg; } } // Mailer thanks Paul
Re: web.xml question
Not really, if you have a servlet is used for startup a background process, then you do not need a mapping section. - Original Message - From: Pooleery, Manoj [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Monday, February 03, 2003 2:22 PM Subject: web.xml question Is it necessary that for each of the servlet elements in the web.xml, a corresponding servlet-mapping element should be there? (For a context other than root). Thanks -Manoj. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
error when startup tomcat.
Hi, I install Tomcat/4.1.18 and I have my web.xml in my application. I try to keep web.xml very simple first, but I got this error when I try to start tomcat. Any one has same experience, please give me advice. This web.xml is working under tomcat/3.3.2 my web.xml is ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app display-nameWelcome to SmartEquip/display-name description Welcome to SmartEquip /description context-param param-namewebmaster/param-name param-value[EMAIL PROTECTED]/param-value description The EMAIL address of the administrator to whom questions and comments about this application should be addressed. /description /context-param session-config session-timeout100/session-timeout /session-config servlet servlet-nameAddInvalidPOServlet/servlet-name servlet-classcom.smartequip.servlet.AddInvalidPOServlet/servlet-class /servlet servlet-mapping servlet-nameAddInvalidPOServlet/servlet-name url-pattern/servlet/AddInvalidPOServlet/url-pattern /servlet-mapping /web-app and the error on tomcat console: Jan 31, 2003 3:58:13 PM org.apache.commons.digester.Digester error SEVERE: Parse Error at line 36 column 11: The content of element type web-app must match (icon?,display-name?,description?,distributable?,context-param*,filt er*,filter-mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-map ping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,sec urity-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref *). org.xml.sax.SAXParseException: The content of element type web-app must match (icon?,display-name?,description?,distributable?,context-param*,filter*,filter- mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welco me-file-list?,error-page*,taglib*,resource-env-ref*,resource-ref*,security-const raint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*). at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Er rorHandlerWrapper.java:232) at org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper. java:173) Paul Hsu
Need Help
) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530) at java.lang.Thread.run(Thread.java:536) 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path /manager 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path /examples 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path /smartequip 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path /tomcat-docs 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path /webdav 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path 2003-01-31 17:59:23 StandardHost[localhost]: Removing web application at context path /admin Paul Hsu