Coldfusion 9 doesn't see java servlets annotated by WebServlet annotation.

Hi.
I'm trying to run java servlet application on coldfusion 9 running on top of iis 7 server.
Also i'm using java 1.7.
Coldfusion seems doesn't see servlets annotated by WebServlet annotation. I get 404 server response.
If i add servlets mapping in web.xml everything works fine, except one thing, my application uses WebSockets, which doesn't has xml configuration,
only annotation @ServerEndpoint.
So i can't figure out, why my annotations don't work.
According to coldfusion 9 and java ee, annotations should work and it depends on java version which i use with coldfusion.
Could you help me please, may be there is a some attribute which i need to set to use annotations like @WebServlet or something like this.
Thanks.

ColdFusion 9 "does see" Java Servlets annotated by the WebServlet annotation. A 404 response means in all likelihood that there is a path issue. Verify that your annotation's url-patterns attribute includes the path to the ColdFusion page calling the Servlet.

Similar Messages

  • How to convert old Java Servlets to OSGi "Servlet" Bundles

    Hello I'm looking for some help/insight on the best way to convert some of our old Java Servlet code into new OSGi Bundles that can be accessed as servlets.  I'd like to be able to install the new bundles then access them on one of our CQ instance using something like "/servlet/servlet_name".
    So far I've been able to create a new bundle, and install it into CQ but I haven't been able to access the bundle at the servlet mapping URL that I would expect.  So far what I've found online has lead me to believe that I need to use the Felix Annotations to describe my servlet.
    @Component(immediate = true, metatype = true, label = "Servlet Name")
    @Service
    @Properties({
        @Property(name = Constants.SERVICE_DESCRIPTION, value = "Servlet Name"),
        @Property(name = "sling.servlet.methods", value={"GET"}),
        @Property(name = "sling.servlet.paths", value = "/servlet/my_servlet_mapping"),
        @Property(name = Constants.SERVICE_VENDOR, value = "VendorName")
    public class TellAFriend extends HttpServlet {...
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
    Once I have this installed, and running without an error in the logs for CQ I tried to go on my local instance to http://localhost:4502/servlet/my_servlet_mapping but I only get 404 Resource Not Found errors.  I've even gone to the Sling Resource Resolver and it doesn't resolve to anything either.
    Is there more than the Servlet Information need into the Annotations to convert "old" code into a new OSGi Servlet Mapped Bundle?

    I must be missing something else configuration wise since I created a new Servlet basically using the code you provided above.  I deployed it as part of the bundle that I'm trying to create.
    The bundle installs and stars fine but I still can't access the servlet.  Are there CRXDE based configurations that are requried too to configure Servlets. 
    Here's my test servlet file.  I tried going to http://localhost:4502/servlet/TestCQServlet and just get the same 404 error I'm getting for the other 2 Servlets Java classes in my Bundle.
    import java.io.IOException;
    import javax.servlet.ServletException;
    import org.apache.felix.scr.annotations.sling.SlingServlet;
    import org.apache.sling.api.SlingHttpServletRequest;
    import org.apache.sling.api.SlingHttpServletResponse;
    import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
    @SlingServlet(paths = "/servlet/TestCQServlet", methods = "GET")
    public class TestCQServlet extends SlingSafeMethodsServlet {
        // @Reference
        // private Repository repository;
        private static final long serialVersionUID = 6239754936223276983L;
        @Override
        protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException {
            response.setHeader("Content-Type", "application/json");
            response.getWriter().print("whatever");

  • Help: No Parameters, HTML Output from Java Servlet

    I have a Java Servlet that reads parameters passed from an HTML form and displays them to another HTML page. I know the servlet is being invoked; however, I am not seeing any HTML output. Sending the output to a file reveals the parameters are coming in as NULL as well.
    I attempted a simple sample app with the same results. Here is what I am running:
    The HTML Form:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Collecting Three Parameters</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FDF5E6">
    <H1 ALIGN="CENTER">Collecting Three Parameters</H1>
    <FORM ACTION="ThreeParams">
    First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
    Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
    Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
    <CENTER><INPUT TYPE="SUBMIT"></CENTER>
    </FORM>
    </BODY>
    </HTML>
    The Java Code:
    public class ThreeParams extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading Three Request Parameters";
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +
    "<UL>\n" +
    " <LI><B>param1</B>: "
    + request.getParameter("param1") + "\n" +
    " <LI><B>param2</B>: "
    + request.getParameter("param2") + "\n" +
    " <LI><B>param3</B>: "
    + request.getParameter("param3") + "\n" +
    "</UL>\n" +
    "</BODY></HTML>");
    What happens when I "submit" from the form is the same form reloads with the query string in the URL: "http://localhost:8080/ThreeParams/?param1=1&param2=2&param3=3"
    Any assistance with either (or both) would be thoroughly appreciated:
    a) why the parameters are not being passed correctly to the servlet
    b) why the HTML output page is not displayed
    Thanks in advance!
    - Steve

    I have found the answer to my problem listed in another thread.
    Thank you.

  • Calling a COBOL stored proc from Java Servlet

    I am trying to call a COBOL stored proc from a Java Servlet. The stored proc is stored on a DB2 database. I need to send 6 inputs to the COBOL stored proc and the output will be the return code of the stored proc. I'm not sure if I'm going about this the right way. This is how my code looks...
    public int callStoredProc(CallableStatement cstmt,
    Connection con,
    String sYear,
    String sReportNbr,
    String sSystemCode,
    String sUserId,
    String sModuleNbr,
    String sFormId){
    int iParm1 = 0;
    try{
    Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(ClassNotFoundException ex){
    System.out.println("Failed to locate database driver: "
    + ex.toString());
    return iParm1;
    try{
    cstmt = con.prepareCall("{? = CALL MKTPZ90C
    cstmt.registerOutParameter(1, Types.INTEGER);
    cstmt.setString(2, sYear);
    cstmt.setString(3, sReportNbr);
    cstmt.setString(4, sSystemCode);
    cstmt.setString(5, sUserId);
    cstmt.setString(6, sModuleNbr);
    cstmt.setString(7, sFormId);
    cstmt.execute();
    iParm1 = cstmt.getInt(1);
    CloseSQLStatement(cstmt);
    catch(SQLException ex) {
    CloseSQLStatement(cstmt);
    System.out.println("SQL exception occurred:" +
    ex.toString());
    return iParm1;
    return iParm1;
    Could someone tell me if this is the right way to go about doing this?
    Thanks!!!!!!

    I didn't see the code where you create the database connection (variable "con"). However, the answer to your question "Is this the right way...", for me, is "Anything that works is the right way." So try it. That's a first approximation, but once you have something that works you can start on improving it, if that becomes necessary.

  • When Streaming a PDF from a java servlet I get a grey screen on the Adobe Reader X plugin.

    I work on a webapp where we serve pdfs to clients by streaming via java servlets. Once we began to use Reader X we noticed that in IE the pdf will load Reader X with a grey screen. Chrome and firefox both work perfectly fine. If we use Adobe 9 it also works fine. We have no control over what our users use so any client side fix is not useful.
    We serve these pdfs to our user by opening a popup window to a url that streams the pdf directly to the response. We have noticed that if we have one popup window that has hit the grey screen - each new pdf in a popup works correctly - as long as the original grey screen is up, once all popups are closed the problem happends again. Refreshing the window with the grey screen will also show the pdf correctly.
    The problem is very similar to what is described here:
          http://forums.adobe.com/message/3335266
    However, we are not setting any caching headers - I have full control over what we can send and I have tried the suggestions - nothing works. Any ideas how to resolve this?

    You are prevented from Airplay mirroring certain things like DVD content as the material is usually protected so you get a checkerboard type display.  I think there is a theoretical risk that the Airplay stream could be intercepted and the protected video copied, albeitin lower quality.
    Apple may be being cautious or are required to do so with the DVD player app by movie studios/licensing authorities.  It makes no sense to the average consumer who is just trying to send their purchased DVD to the TV via the computer and AppleTV.
    Playback in something like VLC should work - not tried it myself but others have commented it doesn't have the restriction.

  • Java servlets - JDBC

    hi,
    I have a problem... i would like to fetch some strings from the database using JDBC and create a tree structure using java servlets to be displayed on a browser using html.
    Currently i have tried using a hashtable as well as defaultmutabletreenode, both of which grew complicated and did not give the desired results.
    Pls help...

    I tried using both a DefaultMutableTreeNode
    containing all the other nodes as child nodes and a
    hashtable with a series of internal hashtables -- and
    passed it to the servlet displaying the html
    l content.
    Is there a better/simpler data structure to use in
    this case other than a Hashtable and a
    DefaultMutableTreeNode?How should we know? You're asking what is better to solve your problem, without saying what your problem is. (Hint: "I can't do this" or "It doesn't work" are not useful problem descriptions.)
    If I were doing this, and if I had to build a tree structure in memory before producing HTML from it, I would use DefaultMutableTreeNode. But then I don't know anything about your problem.

  • Problem Installing Java Servlets Package

    I downloaded a sample servlet program which imports classes from the Java Servlets Package. I have the JDK 1.2 which does not come with the servlet classes (javax.servlet and javax.servlet.http). So I then downloaded them from java.sun.com. They come as a set of class files in .zip format. I thought packages were supposed to be in .jar format? At any rate, my compiler still fails to see these classes even after I have extracted these files into the same directory as the original .zip file and added this directory to my classpath. Am I going about this the wrong way? Any ideas on how I can make my compiler see these classes? --Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I down loaded j2sdk 1.4 . and also down loade servlet package. I installed in bin directory.
    i took the sample program and compiled. there is error message " java servlet package not found.
    please help. email me at [email protected]
    Thanks
    sri

  • Problems calling Java Servlets from HTML pages Online

    Hello
    I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
    http://localhost:8080/servlet/....
    followed by the name eg.
    http://localhost:8080/servlet/Login
    however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
    i.e ..servlet/Login.java
    I was wondering would anyone have any idea as in how the servlets should be called
    Thanks very much

    Once you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
    -Mak

  • Unicode, UTF-8 and java servlet woes

    Hi,
    I'm writing a content management system for a website about russian music.
    One problem I'm having is trying to get a java servlet to talk Unicode to the Content mangament client.
    The client makes a request for a band, the server then sends the XML to the client.
    The XML reading works fine and the client displays the unicode fine from an XML file read locally (so the XMLReader class works fine).
    The servlet unmarshals the request perfectly (its just a filename).
    I then find the correct class, and pass it through the XML writer. that returns the XML as string, that I simply put into the output stream.
    out.write(XMLWrite(selectedBand));I have set correct header property
    response.setContentType("text/xml; charset=UTF-8");And to read it I
             //Make our URL
             URL url = new URL(pageURL);
             HttpURLConnection conn = (HttpURLConnection)url.openConnection();
             conn.setRequestMethod("POST");
             conn.setDoOutput(true); // want to send
             conn.setRequestProperty( "Content-type", "application/x-www-form-urlencoded" );
             conn.setRequestProperty( "Content-length", Integer.toString(request.length()));
             conn.setRequestProperty("Content-Language", "en-US"); 
             //Add our paramaters
             OutputStream ost = conn.getOutputStream();
             PrintWriter pw = new PrintWriter(ost);
             pw.print("myRequest=" + URLEncoder.encode(request, "UTF-8")); // here we "send" our body!
             pw.flush();
             pw.close();
             //Get the input stream
             InputStream ois = conn.getInputStream();
                InputStreamReader read = new InputStreamReader(ois);
             //Read
             int i;
             String s="";
             Log.Debug("XMLServerConnection", "Responce follows:");
             while((i = read.read()) != -1 ){
              System.out.print((char)i);
              s += (char)i;
             return s;now when I print
    read.getEncoding()It claims:
    ISO8859_1Somethings wrong there, so if I force it to accept UTF-8:
    InputStreamReader read = new InputStreamReader(ois,"UTF-8");It now claims its
    UTF8However all of the data has lost its unicode, any unicode character is replaced with a question mark character! This happens even when I don't force the input stream to be UTF-8
    More so if I view the page in my browser, it does the same thing.
    I've had a look around and I can't see a solution to this. Have I set something up wrong?
    I've set, "-encoding utf8" as a compiler flag, but I don't think this would affect it.

    I don't know what your problem is but I do have a couple of comments -
    1) In conn.setRequestProperty( "Content-length", Integer.toString(request.length())); the length of your content is not request.length(). It is the length of th URL encoded data.
    2) Why do you need to send URL encoded data? Why not just send the bytes.
    3) If you send bytes then you can write straight to the OutputStream and you won't need to convert to characters to write to PrintWriter.
    4) Since you are reading from the connection you need to setDoInput() to true.
    5) You need to get the character encoding from the response so that you can specify the encoding in           InputStreamReader read = new InputStreamReader(ois, characterEncoding);
    6) Reading a single char at a time from an InputStream is very inefficient.

  • Questions about Java Servlets and JSP

    Hi,
    I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
    I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
    I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
    I have a few questions:
    How should I start to learn JS and JSP?
    How applicable will the java knowlegdge I have already be?
    Are JSP common on the world wide web?
    What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
    Is it likey my web host (and others) will support JSP?
    Thank-you very much for helping a novice get started,
    Regards,
    Paul

    Hi, Steve ...has to be frustrating! But do not despair.
    Let's suppose the servlet it's named MyServlet on package org.servlets
    WEB-INF should look:
    WEB-INF
    classes
    org
    servlets
    MyServlet.class
    web.xml
    web.xml file should have this two declarations:
    <web-app>
      <servlet>
        <servlet-name>MyServlet</servlet-name>
        <servlet-class>org.servlets.MyServlet</servlet-class>
      </servlet>
      <!-- other servlets -->
      <servlet-mapping>
        <servlet-name>MyServlet</servlet-name>
        <url-pattern>/MyServlet</url-pattern>
      </servlet-mapping>
      <!-- other servlets mappings -->
    </web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
    http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
    Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

  • Java Servlet Error in oracle 10.1.2 (10g)

    Hello,
    This question belongs to our company project,which is a Govt.Organization. We are using AIX 5.3 Server OS with Oracle 10.1.2 (10g) Application Server on it.
    We have installed all the above OS & Oracle Application on IBM P-Series High End Servers.
    Now, We have successfully installed "Oracle 10g AS" on AIX but after installation, we are getting some common errors which is related to JAVA & Servlet. Below is the error file.
    09/05/02 19:01:50 Started
    09/05/02 19:01:51 vatwebsite: jsp: init
    09/05/02 19:01:51 vatwebsite: FrontServlet: init
    09/05/02 19:01:52 vatwebsite: action: init
    09/05/02 19:01:54 vatwebsite: barbecue: init
    09/05/02 19:01:54 vatwebsite: Started
    09/05/02 19:01:55 vatwebsite: Servlet error
    java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java(Compiled Code))
        at java.util.HashMap$KeyIterator.next(HashMap.java(Compiled Code))
        at java.util.Collections$6.nextElement(Collections.java:2493)
        at org.apache.struts.util.RequestUtils.getModulePrefixes(RequestUtils.java:1907)
        at org.apache.struts.util.RequestUtils.getModuleName(RequestUtils.java:1803)
        at org.apache.struts.util.RequestUtils.getModuleName(RequestUtils.java:1788)
        at org.apache.struts.util.RequestUtils.selectModule(RequestUtils.java:1768)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1481)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
        at com.vat.website.utils.LogRecorderServlet.doPost(LogRecorderServlet.java:38)
        at com.vat.website.utils.LogRecorderServlet.doGet(LogRecorderServlet.java:29)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
        at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
        at java.lang.Thread.run(Thread.java:568)
    I need some solution to remove this error. Kindly let me know how to go further to sort out this error. Another thing is,I am not a JAVA/Programmer person But still this is a part of my job.
    So,please do the needful & provide me some guidence & document about "How to solve this JAVA Error".
    Advanced Thanks,
    Nishith Vyas.

    See this thread for a JDBC bug number reference
    JDev 10.1.3 : Error running my first ADF application.

  • Some questions about Java servlets

    I am having some problems with my Java servlets. Here they are below.
    #1 I have a login jsp page. When user logs in, the MySQL database is queried. If a match, redirect to appropriate page. The problem is I can't seem to remain in the login page if there is no match, I get a blank screen. If there is no match, how can I redirect it back to the login screen? For example, my login screen is login.jsp. Here is my code below.
    while(rs.next())
    if(rs != null)
    String name = rs.getString("USERNAME");
    Cookie getUser = new Cookie("User", name);
    response.addCookie(getUser);
    String sql2 = "INSERT INTO answers (USERNAME) VALUES( '" + name +"')";
    ResultSet rs2 = stmt.executeQuery(sql2);
    response.sendRedirect("profile410.jsp");
    out.println("<p>inside if structure");
    #2 After I go to the first screen after login, I am filling out a questionaire, and everytime I click on a submit button a different servlet comes into play, called InsertRecords.java. Everytime I go from one jsp to another, information gets stored into a database, InsertRecords.java is controlling this. I use the below code.
    String delete = request.getParameter("delete");
    String question = request.getParameter("question");
    String value = request.getParameter("R");
    if (delete.equals("no") && !value.equals(""))
    String sql = "INSERT INTO answers (" + question + ") VALUES (" + value + ")";
    int numRows = stmt.executeUpdate(sql);
    out.println("Record has been inserted");
    String nextPage = request.getParameter("nextPage");
    Cookie[] cookies = request.getCookies();
    if (cookies != null)
    for (int i = 0; i < cookies.length; i++)
    String name = cookies.getName();
    String valuecook = cookies.getValue();
    Cookie getUser = new Cookie(name, valuecook);
    response.addCookie(getUser);
    response.sendRedirect(nextPage);
    the table is answer and the fields are ID, username, and q1, q2 q3, up to q11. the idea is upon login, the username gets stored into the answer table, the field username. I want the values stored in the same row everytime user jumps from one page to another based on his username. Goes to first jsp, q1 gets inserted, next jsp, q2 gets inserted, etc. But they all get inserted diagonally on different rows, not the same one, that is the problem. How can I fix this?
    #2 Based on the above code, say there is 11 jsp pages, remember, this is an online questionaire. When user logs in, he starts at the first jsp page, or question. When for example when the browser gets cut off at question6, when he logs back in, I want him to start at question4, if cut of at question 11, start again upon login at question 8. The reason, so he won't have to start from the beginning. Each question is on seperate jsp's. The way I see this happening is creating a session upon login and keeping that session. And grab 4th question when he logs back in, but I am not sure about how to go about it.
    Can someone help me please?

    Q1:
    Use the update command and not insert.
    Q2:
    Won't work. The user may log back in after the session has expired or from a different location. On log in look for a record for that user and what questions have been answered so far.

  • Calling XSQL from java servlet

    I'm able to call XSQL, process the page, and display it. But, how do I set the stylesheet from within my java servlet.
    I tried params.put( "xml-stylesheet", "[path to sheet]" ), and then passing that to process(), but it just ignores it. I want to be able to set the stylesheet dynamicaly like when you call XSQL from the command line or from the XSQL servlet.
    XSQLRequest req = new XSQLRequest( xsql );
    Hashtable params = new Hashtable(2);
    params.put( "mths", "6");
    params.put( "run_id", "30");
    params.put( "grade", "A" );
    params.put( "xml-stylesheet", xsl ); <-- just seems to ignore this.
    ByteArrayOutputStream ostr = new ByteArrayOutputStream(2048);
    req.process( params, ostr, new PrintWriter(System.err) );

    Thanks for the help Steve (and thanks for a really nice book by the way.)
    To answer your first question, I have implemented a report caching servlet. In the application we're writing, reports are generated in HTML or PDF (using XSQL) on demand. However, the data really only changes once a day at most so I wanted to have a way to store the reports once they were generated. So this servlet basically gets the request for a report, checks to see if the report has already been generated and, if not, generates the report using XSQLRequest. Finally it returns the report to the user.
    One benefit to doing this is that it masks the generation process from the user (ie, they can just hit a link like http://somehost/path/to/report.pdf and they get a pdf report.) Of course the other benefit is that reports only need to be generated once, reducing server load.
    I will definitely try your suggestion and just redirect to the XSQL servlet. I guess I was thinking about it too hard, this is a simple solution which will probably address the problem with a minimum of fuss. ;o) Using XSQLRequest directly works, it's just that I want to be able to reference external images using relative paths... it's funny that relative references to XSL pages works though.
    Thanks again,
    Van
    null

  • Using forward(request, response) in Java Servlet

    Hi
    I need help on how to use the forward() method in a java servlet passing a List object and riderecting to another jsp.
    when I use the following code;
    request.getRequestDispatcher(path).forward(request, response);
    I'm getting this message:
    Content modified /content...
    Status
    200
    Message
    OK
    Location
    /content...
    Parent Location
    /content
    Path
    /content...
    Referer
    Thanks,

    Looking at your traces seems like you are forwarding during POST. Seems like issue with your component implementation missing with POST & proxy scripts. Please eloborate more on the exact steps you are following. Alternatively See if this helps.
    org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper req =
    new org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper(slingRequest) {
    public String getMethod() {
    return "GET";
    String path = "/content/.../test.html";
    javax.servlet.RequestDispatcher dispatcher = slingRequest.getRequestDispatcher(path);
    dispatcher.include(req, slingResponse);

  • Java servlet to send audio file

    Hi, I have used the example in this link http://www.java2s.com/Code/Java/Servlets/Sendmp3.htm to send a wav file to the client. I have changed the content type to audio/x-wav as I am sending a wav file not mp3 as in the example.
    For some reason, it seems to send something back, but the audio file does not have any data in it (0 bytes). Eg try this link to see what happens: http://mel.our-lan.com/?=barcode50214561353872
    The file browser opens up winamp/media player, but the file has no data in it. Can anybody see the problem in my code?:
    String fileName = "";
                        while (rs.next())
                             fileName = rs.getString("SoundClip");
                        if (fileName == null || fileName.equals(""))
                             throw new ServletException(
                               "Invalid or non-existent file parameter in barcodeServlet.");
                        String wavDir = ("http://mel.our-lan.com/wav-dir/" + fileName);
                             /*getServletContext().getInitParameter("wav-dir");*/
                        if (wavDir == null || wavDir.equals(""))
                          throw new ServletException(
                               "Invalid or non-existent wavDir context-param.");
                        ServletOutputStream stream = null;
                        BufferedInputStream buf = null;
                        try
                             stream = response.getOutputStream();
                             File wav = new File(wavDir + "/" + fileName);
                             //set response headers
                             response.setContentType("audio/x-wav");
                             response.addHeader("Content-Disposition", "attachment; filename="
                                  + fileName);
                             response.setContentLength((int)wav.length());
                             FileInputStream input = new FileInputStream(wav);
                             byte[] buf1 = new byte[1024];
                             int len;
                             while ((len = input.read(buf1)) > 0)
                                  stream.write(buf1, 0, len);
                             /* TRIED THE FOLLOWING ASWELL BUT SAME RESULT:
                                            buf = new BufferedInputStream(input);
                             int readBytes = 0;
                             //read from the file; write to the ServletOutputStream
                             while ((readBytes = buf.read()) != -1)
                                  stream.write(readBytes);*/
                             input.close();
                        catch (IOException ioe)
                             throw new ServletException(ioe.getMessage());
                        finally
                             if (stream != null)
                                  stream.close();
                             if (buf != null)
                                  buf.close();
                        }

    I tried the link; got the following:
    java.lang.NullPointerException
         BarcodeServlet.doPost(BarcodeServlet.java:23)
         BarcodeServlet.doGet(BarcodeServlet.java:17)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)Take a look at this example, [1],might help you some.
    [1] http://balusc.blogspot.com/2007/07/fileservlet.html
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

Maybe you are looking for

  • Mail count in the dock

    I no longer see a red count of unopened mail in the dock. I found in the settings I can click 'dock unread count' to show, but it still does not.  Suggestions?

  • Invoke Siebel OnDemand Web Service via BPEL

    Hi, We are trying to invoke Siebel OnDemand Web Service via BPEL. We have followed the steps as mentioned in http://www.oracle.com/technetwork/topics/ofm-siebel-blog-postings-092216.html But still we are unable to get the Session Id. Do we need to op

  • Displaying hex values when editing a numeric control

    The hex display is removed when editing a numeric control (in Control Settings) in cvi 2012. Is this a bug or am I missing something? Solved! Go to Solution.

  • Question about Compression

    So i have Mac The Ripper and Toast 7 and have never had a problem like this before. I have a window pop up on Toast saying "The contents of this Videos_TS folder cannot be compressed" Is there any way around this?

  • Unable to deploy ear file to weblogic 11g

    Unable to access the selected application. Exception in AppMerge flows' progression Exception in AppMerge flows' progression VALIDATION PROBLEMS WERE FOUND problem: cvc-attribute.4: The value '6' does not equal the fixed value '5' of attribute 'versi