Servlet crossroad

Hi! I hope you can help me!! I am having this problem. I am working for a multinational information service provider here in Costa Rica.
They have a product that has a web page application. This application is aimed to the telcomunications industry and allows people to send messages via internet to a cell phone (ye, I know it sounds silly at this time...but we are a little behind here...but trying to catch up!! in the next few months). This page contains just two fields...the phone field and the message field and another one that is hidden that is the type of process the user is sending, either if it is a message or a query. This values are send to a servlet via request response and this sesrvlet, that does some calculations and set some variables, calls another class and send the input of the user to that class passing them the request response arguments as parameters.( This servlet does not do a request parameter. That is done by another class).
The local telecom company bought the product but wants to customize it a little bit, mainly allowing people to send the same message not to one, but to five cellphones. And the other one is that they do not want the user to write the phone number. Instead they want to replace that field to an alias field, so the application takes that alias, validates that it exists in the data base, takes the associated phone number and then sends the message, with both the phone number and the message as parameters.
The problem I am having is that I do not have the source code of the product, so I can not make modifications to it. I have already developed the authentication part of the process. The problem tha I have is that the method of the class that sends the message takes a request response parameter, and do not aks for all the parameters send in the request, it just ask for the specified phone field and the message field via the requesParameter method in each case. In my case I do not have problems with the message field because it is indeed in the request, but first of all, the phone mesasge it is not part of the request, the applications takes it from a database, and second of all, even if it was part of the request, the class that sends the message asks just for one phone field. And as I said before, I do not have the resource code, so I can not change that.
I nknow I can put an attribute in the request and send it, but that willnot work because I can not modify the class and I do not even know who it does the work it does.
My question is...is there a way to change the request variable? I thought that if a servlet can take all the five phone number and doing a loop sending a new request to the class that takes the message with just one phone number and one message...but I do not know how to do that or if that can be done...
Can you help me?

Thakn you all for your help. I find the way to add a parameter in the request, so I can modify it and send that new request to the servlet of the product. I just add the two parameter with the name they have in the original html page in one servlet and then pass the new request to the servlet of the telepohe part of the product, and it just woks perfect!!
What I could not do, however, was to send more than one message. That is becuase the servlet calls a class that has a response method that is called every time you send a message and it is presented to the user in an html page. When I call the servlet of the product, I pass the control of the flow to that servelt, so I do not have a way to stop that flow because of the source code problem I already told you.
But I think the client will be just fine not having to present to the final user two pages for the message.

Similar Messages

  • Get all values from multi select in a servlet

    Hello,
    I have a multi <select> element in a HTML form and I need to retrieve the values of ALL selected options of this <select> element in a servlet.
    HTML code snippet
    <select name="elName" id="elName" multiple="multiple">
    Servlet code snippet
    response.setContentType("text/html");
    PrintWriter out = null;
    out = response.getWriter();
    String output = "";
    String[] str = request.getParameterValues("elName");
    for(String s : str) {
    output += s + ":";
    output = output.substring(0, output.length()-1); // cut off last deliminator
    out.println(output);But even when selecting multiple options, the returned text only ever contains the value of the first selected option in the <select>
    What am I doing wrong? I'm fairly new to servlets
    Edited by: Irish_Fred on Feb 4, 2010 12:43 PM
    Edited by: Irish_Fred on Feb 4, 2010 12:44 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:14 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:26 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:26 PM
    Edited by: Irish_Fred on Feb 4, 2010 2:32 PM

    I am using AJAX.
    I will show you how I'm submitting the <select> values by showing you the flow of code:
    This is the HTML code for the <select> tag and the button that sends the form data:
    <form name="formMain" id="formMain" method="POST">
         <input type="button" id="addOpts" name="addOpts" value="Add Options" style="width:auto; visibility:hidden" onClick="jsObj.addOptions('servletName', document.getElementById('elName'))">
         <br>
         <select name="elName" id="elName" multiple="multiple" size="1" onChange="jsObj.checkSelected()">
              <option value="0"> - - - - - - - - - - - - - - - - </option>
         </select>
    </form>Note that the "visibility:hidden" part of the button style is set to "visible" when at least one option is selected
    Note that "jsObj" relates to a java script object that has been created when the web app starts ( The .js file is included in the .jsp <head> tag )
    The following code is taken from the file: "jsObj.js"
    jsObj = new jsObj();
    function jsObj() {
    //=================================================
         this.addOptions = function(url, elName) {
              var theForm = document.getElementById('formMain');          
              if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
                   xmlhttp=new XMLHttpRequest();
              } else { // code for IE6, IE5
                   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              url += this.buildQueryString(theForm.name);
              xmlhttp.open("POST",url,true);
              xmlhttp.send(null);
              xmlhttp.onreadystatechange=function() {
                   if(xmlhttp.readyState==4) { // 4 = The request is complete
                        alert(xmlhttp.responseText);
    //=================================================
    this.buildQueryString = function(formName) {
              var theForm = document.forms[formName];
              var qs = '';
              for (var i=0; i<theForm.elements.length; i++) {
                   if (theForm.elements.name!='') {
                        qs+=(qs=='')? '?' : '&';
                        qs+=theForm.elements[i].name+'='+escape(theForm.elements[i].value);
              return qs;
         //=================================================
    }And this is a code snippet from the "servletName" servlet:public synchronized void doGet(HttpServletRequest request,
              HttpServletResponse response) throws ServletException,IOException {
              PrintWriter out = null;
              try {
                   response.setContentType("text/html");
                   out = response.getWriter();
                   String output = "";
                   String[] values = request.getParameterValues("elName");
                   for(String s : values) {
                        output += s + ":";
                   output = output.substring(0, output.length()-1); // cut off last delimitor
                   out.println(output);
                   } catch (Exception e) {
         }So anyway, everthing compiles / works, except for the fact that I'm only getting back the first selected <option> in the 'elName' <select> tag whenever I select multiple options
    Edited by: Irish_Fred on Feb 7, 2010 10:53 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Open Jasper Report in new page using servlet

    Guys,
    Looks very simple but i am having problem making this process work. I am using 11.1.1.4
    This is my use case:
    - From a employee page, user clicks on a menu item to open report for current employee. I need to pass appropriate report parameters to servlet and open report into new page.
    I can successfully call servlet using commandmenuitem and set request parameters and call servlet from backing bean.... but that doesn't open report in a new page.... any way i can do this?
    Another option i tried was that using gomenuitem and setting target=blank but in that case i need to pass the parameter using servlet url which i like to avoid.(in case i need to pass many parameters in future) (also values will be set on page so i need to generate url when then click the menuitem...... so there are some hoops and loops i need to go through) I don't know a way to pass the request parameter using backing bean to servlet... i don't think it is possible.
    Those are the two approaches i tried.
    If you have any better approach...I would appreciate if you can let me know. (i have searched on internet for two days now.... for the solution)
    -R
    Edited by: polo on Dec 13, 2011 7:22 AM

    Hi,
    Hope following will useful
    http://sameh-nassar.blogspot.com/2009/10/using-jasper-reports-with-jdeveloper.html
    http://www.gebs.ro/blog/oracle/jasper-reports-in-adf/

  • How can i execute ejb method in a servlet?

    hi
    I am using a IBM HTTP Server and Weblogic Server.
    I could execute below source in a main method of application but i could not that in a init method of servlet because of ClassCastException.
    (a classpath of weblogic contains client's classpath)
    // source code
    Hashtable props = new Hashtable();
    props.pu(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL,
    "t3://192.168.1.5:7001");
    Context ctx = new InitialContext(props);
    Object obj = ctx.lookup("session.LigerSessionHome");
    LigerSessionHome home = (LigerSessionHome) PortableRemoteObject.narrow (obj, LigerSessionHome.class);
    // error code
    Exception : session.LigerSessionBeanHomeImpl_ServiceStub
    java.lang.ClassCastException: session.LigerSessionBeanHomeImpl_ServiceStub
    at com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:253)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:136)
    at credit.getCreditResearch(credit.java:41)
    at creditResearchClient.doGet(creditResearchClient.java:122)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    thanks

    Have your stubs somehow got out of sync? So that your Servlet engine is pointing to a different jar than that of your jvm on which you were running your client application
    hi
    I am using a IBM HTTP Server and Weblogic Server.
    I could execute below source in a main method of
    application but i could not that in a init method of
    servlet because of ClassCastException.
    (a classpath of weblogic contains client's classpath)
    // source code
    Hashtable props = new Hashtable();
    props.pu(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    props.put(Context.PROVIDER_URL,
    "t3://192.168.1.5:7001");
    Context ctx = new InitialContext(props);
    Object obj = ctx.lookup("session.LigerSessionHome");
    LigerSessionHome home = (LigerSessionHome)
    PortableRemoteObject.narrow (obj,
    LigerSessionHome.class);
    // error code
    Exception :
    session.LigerSessionBeanHomeImpl_ServiceStub
    java.lang.ClassCastException:
    session.LigerSessionBeanHomeImpl_ServiceStub
    at
    com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(Porta
    leRemoteObject.java:253)
    at
    javax.rmi.PortableRemoteObject.narrow(PortableRemoteObj
    ct.java:136)
    at credit.getCreditResearch(credit.java:41)
    at
    creditResearchClient.doGet(creditResearchClient.java:12
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java
    740)
    at
    javax.servlet.http.HttpServlet.service(HttpServlet.java
    865)
    thanks

  • How to call a specific method in a servlet from another servlet

    Hi peeps, this post is kinda linked to my other thread but more direct !!
    I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?
    Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.
    I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ??
    Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ???
    Cheers
    Kevin

    Thanks for the reply.
    So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?
    getrequestdispatcher.include(newDAO.login())
    where newDAO is an instance of the class DAO, would that be correct ?? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!
    Kevin

  • Error while opening Excel report using servlet

    Hi
    I am using a servlet to open an excel report which has multiple sheets . But there is a weird problem when i try to open an excel report with two sheets having the same name .
    Generally when an excel with same sheet names is opened with Microsoft excel , it will open the excel file with a dialog showing error .
    But when i am trying to open through a servlet after that open/save dialog box comes , its sending two requests and that too the second one from another browser . How i am saying that its sending from another browser is , during the second time its not passing the session checks which i placed .....I mean the session for the request doesn't have any data while it was expected to have some data which i placed in Session while logging in .
    Can any one let me know why this is happening ?/

    Refer Note:280376.1 on MetaLink. Hope this will help you resolve the issue.
    Thanks
    Shail

  • Error while opening a Office 2007 Excel (.xlsx) from a Servlet

    Hi All,
    Actually i am trying to open an excel file from a servlet. It works fine when the file format is .xls. But if it is .xlsx it gives the below error.
    "The file you are trying to open .xlsx is in a different format than specified by the file extension. verify the file is not corrupted and is from trusted source before opening the file. Do you want to open the file now?"
    There is a link in the application. When we click the link it calls the servlet. The servlet calls the DAO. The DAO queries the DB and the whole output is stuffed into a StringBuffer and the StringBuffer is written to the ServletOutputStream. I have used
    File newFile = new File("ABC.xslx");
    response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    I have also included the below in the web.xml file.
    <mime-mapping>
    <extension>xlsx</extension>
    <mime-type>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</mime-type></mime-mapping>
    Kindly help me out.
    Thanks.

    Hi,
    I tried to create an excel through POI 3.5 using a simple java program. I am getting the same error when i try to open it.Below is my code. Kindly let me know the problem.
    I am getting the error ""The file you are trying to open .xlsx is in a different format than specified by the file extension. verify the file is not corrupted and is from trusted source before opening the file. Do you want to open the file now?" when opening the .xlsx file.
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.File;
    import java.io.IOException;
    import java.util.ArrayList;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    public class test {
    public static void main(String args[]) throws IOException{
    //ExportLobBean exportLobsForm = null;
    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet();
    //ArrayList lobList = ExportLobBO.getArrayList();
    //int length = lobList.size();
    int rowCount=0;
    int count=0;
    HSSFRow headerRow = sheet.createRow((short) 0);
    HSSFRow dataRow = null;
    //Creating Column Names
    headerRow.createCell((short)0).setCellValue("LOB-ID");
    headerRow.createCell((short)1).setCellValue("LOB-NAME");
    headerRow.createCell((short)2).setCellValue("WEIGHT");
    for(int i=0;i<5;i++){
    rowCount++;
    sheet.createRow((short)rowCount);
    //exportLobsForm = (ExportLobBean)lobList.get(count);
    headerRow.createCell((short)0).setCellValue(1);
    //LOGGER.info("Lob id "+exportLobsForm.getStrLobId());
    headerRow.createCell((short)1).setCellValue(2);
    //LOGGER.info("Lob name"+exportLobsForm.getStrLobName());
    headerRow.createCell((short)2).setCellValue(3);
    //LOGGER.info("Lob weight"+exportLobsForm.getStrLobWeight());
    count++;
    File f = new File("c:\\test.xlsx");
    FileOutputStream fos = new FileOutputStream(f);
    wb.write(fos);
    }

  • Error while running a Servlet program in Eclipse IDE

    Hi,
    I have tried running the following program in the Eclipse Editor. It doesnt compile. I have installed the Tomcat plugin too.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class HTTPGetServlet extends HttpServlet {
         public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
         throws ServletException, IOException
              PrintWriter output;
              response.setContentTe("text/html");
              output=response.getWriter();
              StringBufer buf=new StringBuffer();
              buf.append("<HTML><HEAD><TITLE>\n");
              buf.append("A simple servlet example\n");
              buf.append("</TITLE></HEAD><BODY>");
              buf.append("<H1>Welcome to the world</H1>\n");
              buf.append("</BODY></HTML>");
              out.println(buf.toString());
              output.close();
    On a closer look i realized that the IDE is showing as error any import statements i type in. Can anyone help me get over this problem? Thanks a lot in advance.
    bye
    V

    You need to add the JAR containing the servlet API in the external JARs for the project.
    Regards,
    Carol.

  • Error while running Java program which call a file upload servlet

    Hi all,
    I have a java program which calls a servlet and sends the file to be uploaded by the servlet. I used Jbuilder to create java program and servlet program. I compiled both the programs and compilation suceeded and my class files are avaialbe in
    WEB-INF/classes/content directory. But now I am trying to run the Java program(this contains main method) from the command prompt, which should inturn call my servlet.(I have web.xml file inside WEB-INF dir). But I receive the following error
    C:\tomcat5.5.15\apache-tomcat-5.5.16\webapps\content\WEB-INF\classes\content>java MultiContentSender
    Exception in thread "main" java.lang.NoClassDefFoundError: MultiContentSender (w
    rong name: content/MultiContentSender)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
    3)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
    My dir strcture is as below
    TOMCAT_HOME/webapps/content/WEB-INF/classes/content/*.class
    I am not able to figure out the error, can anyone throw some light on this issue.

    You are trying to invoke the class from the command prompt. My guess is that MultiContentSender contains a package, which means that you'll need to add your WEB-INF\classes directory to the classpath before it will work. Classes stored in this directory are expected to be invoked through tomcat, which builds it's own classpath.

  • Can not find my EJB's from my Servlet

    Hi
    I am new to EJB and am trying to get a Servlet to call some sessionless EJB beans. I have got it working in JDeveloper but when I deploy it to orion application server I keep getting a javax.naming.NameNotFoundException exception throw from the Servlet when it tries to find the first EJB.
    The code in the Servlet is:
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "jewels");
    // env.put(Context.PROVIDER_URL, "ormi://localhost:23891/current-workspace-app");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23791/dev");
    Context ctx = new InitialContext(env);
    System.out.println("Getting mapping class ejb");
    //mapping
    ExponentMappingServiceHome mappingHome = (ExponentMappingServiceHome)ctx.lookup("ExponentMappingServiceHome");
    ExponentMappingService mapping = mappingHome.create();
    My EJB xml looks like this:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
    <ejb-jar>
    <enterprise-beans>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>ExponentMappingService</display-name>
    <ejb-name>ExponentMappingService</ejb-name>
    <home>com.exponent.ejb.service.map.ExponentMappingServiceHome</home>
    <remote>com.exponent.ejb.service.map.ExponentMappingService</remote>
    <ejb-class>com.exponent.ejb.service.map.ExponentMappingServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>ExponentMappingViewsService</display-name>
    <ejb-name>ExponentMappingViewsService</ejb-name>
    <home>com.exponent.ejb.service.map.ExponentMappingViewsServiceHome</home>
    <remote>com.exponent.ejb.service.map.ExponentMappingViewsService</remote>
    <ejb-class>com.exponent.ejb.service.map.ExponentMappingViewsServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>FalconService</display-name>
    <ejb-name>FalconService</ejb-name>
    <home>com.exponent.ejb.service.FalconServiceHome</home>
    <remote>com.exponent.ejb.service.FalconService</remote>
    <ejb-class>com.exponent.ejb.service.FalconServiceBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    I have been trying for a while to get the JNDI naming right but everything I try gets the above error. Any help would be great.
    Thanks
    Andre

    You have to lookup for "ExponentMappingService", and not "ExponentMappingServiceHome"
    The name you give in the <ejb-name> tag in ejb-jar.xml is the JNDI name of the EJB. This is the name u have to look up.

  • Post to a servlet from a PL/SQL procedure

    I would like to know if it's possible to post a form from pl/sql. There is this servlet that does stuff but it doesn't have any api i can call so i can only post the parameters to the servlet using an html form. Each form element is added to the http header so i just have to create a header and send it to the servlet but i don't really know how to do this using pl/sql.

    Meanwhile i have found the solution myself.
    This is the snippet that sends a post form to a webpage:
    declare
    v_url varchar2(400) := 'myUrl';
    v_post varchar2(4000);
    HTTP_REQ    utl_http.REQ;
    HTTP_RESP   utl_http.RESP;
    begin
    v_post := 'param1=value1&param2=value2';
    HTTP_REQ := utl_http.BEGIN_REQUEST(v_URL, 'POST', 'HTTP/1.1');
    utl_http.SET_HEADER(HTTP_REQ, 'Content-Type', 'application/x-www-form-urlencoded');
    utl_http.SET_HEADER(HTTP_REQ, 'Content-Length', length(v_post));
    utl_http.WRITE_TEXT(HTTP_REQ, v_post);
    HTTP_RESP := utl_http.GET_RESPONSE(HTTP_REQ);
    end;This post the parameters and values from v_post to the url. In the HTTP_RESP i get the status_code so i can check if it's ok or there was a server error (code 500).

  • Send email from j2me through servlet

    Hi people,
    i hope you can help me because i am new in network programming.
    I am trying to send email from j2me to googlemail account I have 2 classes EmailMidlet (which has been tested with wireless Toolkit 2.5.2 and it works) and the second class is the servlet-class named EmailServlet:
    when i call the EmailServlet, i get on the console:
    Server: 220 mx.google.com ESMTP g28sm19313024fkg.21
    Server: 250 mx.google.com at your service
    this is the code of my EmailServlet
    import java.io.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.text.*;
    import java.util.Date;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class EmailServlet extends HttpServlet {
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws IOException, ServletException {
          System.out.println("____emailservlet.doPost");
          response.setContentType("text/plain");
          PrintWriter out = response.getWriter();
          System.out.println("______________________________");
          out.println();
          String to = request.getParameter("to");
          System.out.println("____________________________to" + to);
          String subject = request.getParameter("subject");
          String msg = request.getParameter("msg");
          // construct an instance of EmailSender
          System.out.println("servlet_to" + to);
          send("[email protected]", to, subject, msg);
          out.println("mail sent....");
       public void send(String from, String to, String subject, String msg) {
          Socket smtpSocket = null;
          DataOutputStream os = null;
          DataInputStream is = null;
          try {
             smtpSocket = new Socket("smtp.googlemail.com", 25);
             os = new DataOutputStream(smtpSocket.getOutputStream());
             is = new DataInputStream(smtpSocket.getInputStream());
          } catch (UnknownHostException e) {
             System.err.println("Don't know about host: hostname");
          } catch (IOException e) {
             System.err
                   .println("Couldn't get I/O for the connection to: hostname");
          if (smtpSocket != null && os != null && is != null) {
             try {
                os.writeBytes("HELO there" + "\r\n");
                os.writeBytes("MAIL FROM: " + from + "\r\n");
                os.writeBytes("RCPT TO: " + to + "\r\n");
                os.writeBytes("DATA\r\n");
                os.writeBytes("Date: " + new Date() + "\r\n"); // stamp the msg
                                                    // with date
                os.writeBytes("From: " + from + "\r\n");
                os.writeBytes("To: " + to + "\r\n");
                os.writeBytes("Subject: " + subject + "\r\n");
                os.writeBytes(msg + "\r\n"); // message body
                os.writeBytes(".\r\n");
                os.writeBytes("QUIT\r\n");
                // debugging
                String responseLine;
                while ((responseLine = is.readLine()) != null) {
                   System.out.println("Server: " + responseLine);
                   if (responseLine.indexOf("delivery") != -1) {
                      break;
                os.close();
                is.close();
                smtpSocket.close();
             } catch (UnknownHostException e) {
                System.err.println("Trying to connect to unknown host: " + e);
             } catch (IOException e) {
                System.err.println("IOException: " + e);
       } 1.when i print "to" in EmailServlet also:
      String to = request.getParameter("to");
          System.out.println("____________________________to" + to);  it show null on the console :confused:
    2. ist this right in case of googlemail.com?
      smtpSocket = new Socket("smtp.googlemail.com", 25);  I would be very grateful if somebody can help me.

    jackofall
    Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    I'm locking this thread now.
    db

  • Couldn't Load DLL and Call JNI in Portal Servlet !!!

    Hello,
    I'm trying to write a small test servlet in portal which will call functions in a DLL using JNI. Here is my source code. I put my DLL in \Window\system32, usr/sap/J2E/JC01/j2ee/os_libs, even included into my portal project \PORTAL-INF\lib. But everytime when I try to preview my page, I got the following error and I couldn't find the log file specified in the error message. Please help me out. Thanks a lot!
    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : N/A
    Component Name : N/A
    MyTestDLL.
    Exception id: 12:25_23/12/06_0029_11241950
    See the details for the exception ID in the log file
    Source Code:
    import com.sapportals.portal.prt.component.*;
    public class CIViewTest extends AbstractPortalComponent
         public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
              response.write("Hello From Java Servlet!!!\n");
         static {
              try {
                   Runtime.getRuntime().loadLibrary("MyTestDLL");
    // I've also tried System.LoadLibrary("MyTestDLL");
              } catch (UnsatisfiedLinkError ule) {
                   throw ule;

    Nobody used JNI in Portal Servlet??? Please advice. Thanks!

  • Can't connect a servlet to a mysql database (jdbc)

    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class LoginServletJDBC extends HttpServlet{
         public void doGet(HttpServletRequest request,HttpServletResponse response)
         throws ServletException,IOException{
              sendLoginForm(response,false);     }
         public void sendLoginForm(HttpServletResponse response,boolean error)
         throws ServletException,IOException{
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html><head>");
              out.println("<title>Login</title>");
              out.println("</head>");
              out.println("<body>");
              out.println("<center>");
              if(error)
                   out.println("<b>Failed login. Please try again</b>");
              out.println("<br><br>");
              out.println("<h2>Login page</h2>");
              out.println("<br>Please enter your username and password");
              out.println("<br><br>");
              out.println("<form method=post>");
              out.println("<table>");
              out.println("<tr>");
              out.println("<td>Username : </td>");
              out.println("<td><input type=text name=userName></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td>Password : </td>");
              out.println("<td><input type=password name=password></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td align=right colspan=3>");
              out.println("<input type=submit value=Login></td>");
              out.println("</tr>");
              out.println("</table>");
              out.println("</form>");
              out.println("</center>");
              out.println("</body></html>");
    public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws ServletException,IOException{
              String userName = request.getParameter("userName");
              String password = request.getParameter("password");
              if(login(userName,password)){
                   RequestDispatcher rd = request.getRequestDispatcher("AnotherServlet");
                   rd.forward(request,response);
              else{
                   sendLoginForm(response,true);
         boolean login(String userName,String password){
              try{
                   String url = "jdbc:mysql://localhost:3306/Users";
                   Class.forName("com.mysql.jdbc.Driver");
                   Connection con = DriverManager.getConnection(url,"root","");
                   //System.out.println("got connection");
                   Statement s = con.createStatement();
                   String sql = "select userName from Users where userName='"+userName+"and password='"+password+"';";
                   ResultSet rs = s.executeQuery(sql);
                   if(rs.next()){
                        rs.close();
                        s.close();
                        con.close();
                        return true;
                   rs.close();
                   s.close();
                   con.close();
              catch(ClassNotFoundException e){
                   System.out.println(e.toString());
              catch(SQLException e){
                   System.out.println(e.toString());
              catch(Exception e){
                   System.out.println(e.toString());
              return false;
    }so ...
    here i'm trying to connect to Users mysql database (i use Tomcat 4.1 and mysql servers and clients 4.0.1-alpha)
    where is the problem ? when i run this servlet (http://localhost:8080/example/servlet/LoginServletJDBC ) it works ;
    BUT when i type an username and a password (any user&pass) my servlet doesn't connect to the database (become a infinite loop without output ; i mean no any errors and exceptions)
    i try other think : i changed the database with unexisting database and the result was that i was expected (Unknow database 'unexistingdatabase' )
    what i miss ?
    please... can anyone help me...
    thank`s in advance

    The wireless security setting that the Actiontec modem/router is using may be different...and not compatible....than the setting that the Comcast product was using.
    If you think that might the case, and you have the time to troubleshoot......
    Temporarily, turn off the wireless security on the Actiontec modem/router
    Reset an AirPort Express back to default settings, then see if it will connect using no security and allow an Internet connection when you do the Ethernet port test in the post above again.
    If the AirPort Express cannot connect correctly using no security on the wireless network.....then it is a no brainer to know that it will never connect when security is enabled.  So, if the AirPort will not connect using no security, you may have an incompatibility issue between the Actiontec and Apple products.
    However, if the AirPort Express connects OK with no security, then this tells you that you will need to use a different setting for security on the Actiontec...the same that the Comcast router was using before.....so the Express will have a better chance of connecting.
    That setting would be something like WPA/WPA2 Personal, or the same setting stated another way would be WPA-PSK-TKIP.

  • Https Connection from servlets using JSSE.

    Hi all,
    Although my question is the same as the QOW for this week, there is an error "unsupported keyword EMAIL" returned when i try to establish a https connection using servlet. The error log is as follow:
    =====================================
    java.io.IOException: unsupported keyword EMAIL
    at com.sun.net.ssl.internal.ssl.AVA.<init>([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.RDN.<init>([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.X500Name.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.X500Name.<init>([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connect([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInputStream([DashoPro-V1.2-120198])
    at URLReader.doGet(URLReader.java:78)
    ===================================
    Does anyone know the meaning of this error?
    I try to write a java application using the similar code and it totally works fine(i can connect to the server and obtain the page). Does JSSE support Java Servlet? Or this is the problem of tomcat server? FYI, I'm using
    Tomcat 3.2.2
    Java SDK 1.3
    Many thanks!
    Ethan
    p.s. Here is the source for my program
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.net.*;
    import javax.net.ssl.*;
    import com.sun.net.ssl.*;
    public class URLReader extends HttpServlet{
    private PrintWriter out = null;
    public void doGet(HttpServletRequest req, HttpServletResponse res){
    res.setContentType("text/html");
    res.setHeader("Cache-Control", "no-cache");
    res.setHeader("Progma", "no-cache");
    out = res.getWriter();
    java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    System.setProperty("javax.net.ssl.trustStore", "File_for_keyStore");
    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    try {
         URL url = new URL("https://server_name:port/index.htm");
         HttpsURLConnection urlconnection = (HttpsURLConnection)url.openConnection();
         BufferedReader in = new BufferedReader(new InputStreamReader(urlconnection.getInputStream()));
         String outputLine ;
         while ( (outputLine = in.readLine()) != null){
         out.println("There is the result: "+outputLine);
         in.close();
    catch(Exception e){
    public void doPost(HttpServletRequest req, HttpServletResponse res){
    }

    I was just having this issue, after months of error-free ssl behavior, on a new machine i was installing (Note: that I was running the IBM jdk1.3) It turns out that when I was editing the java.security file to know about JCE/JSSE providers i had the providers in the wrong order. The Error causing sequence was:
    security.provider.1=com.sun.net.ssl.internal.ssl.Provider
    security.provider.2=com.ibm.crypto.provider.IBMJCA
    # Extra provider added ibm@33894
    security.provider.3=com.ibm.crypto.provider.IBMJCE
    # extra provider i added
    security.provider.4=sun.security.provider.Sun
    The issue disappeared when i changed the order to:
    security.provider.1=sun.security.provider.Sun
    security.provider.2=com.sun.net.ssl.internal.ssl.Provider
    security.provider.3=com.ibm.crypto.provider.IBMJCA
    # Extra provider added ibm@33894
    security.provider.4=com.ibm.crypto.provider.IBMJCE
    hope that helps!
    --john molnar
    Trellis Network Security

Maybe you are looking for

  • User not able to Change Password in Webaccess

    We are running GroupWise 7.0.3 HP3. We have one user who is not able to change her password in Webaccess. Whenever she tries, she get the following error message in Webaccess Ldap Password Change Failed. Contact your system administrator. When I look

  • Emailing .pdf from Acrobat 9

    Hello I seem to be having an issue with emailing pdfs from acrobat. I am recieving an error "Acrobat is unable to connect to your email program" I am using Acrobat 9 running on a 2008r2 terminal server. The email program is Outlook 2010. All other us

  • Stuttering playback on certain clips after render

    Morning, I have just edited a music video for a local band but I've having trouble with the output. The source is AVCHD 1080 50i and I am using that as the project setting too. one of the tracks has 3 0.5 second clips in which plays fine in the timel

  • Authentication works for Wiki but not File Services

    I setup Dual Open Directory Masters for 10.5 Servers, one server contains all my original directory information and is my MCX, File Services, and all the authentication works well on that server. Now I have a second server setup with 10.5 as a second

  • Finder column view out of order

    Hello All, Happy Friday! I have a few Clients where the Finder window column view is listing the files out of alphabetical order. Has anyone seen this before...corrupt Finder pref maybe? Thanks!