Using javax.imageio in JSP

Hi
I have a simple code snippet that I use to read in JPG/GIF image from a file and create a new image that is upside down . Here is my snippet.
//create upside down image
try { 
String imgPath = "\\images\\AINCC.gif";
File fImg = new File(imgPath);
BufferedImage imgREG = ImageIO.read(fImg);
int iW = imgREG.getWidth(null);
int iH = imgREG.getHeight(null);
// Flip the image vertically and horizontally (equivalent to rotating the image 180 degrees)
AffineTransform tx = AffineTransform.getScaleInstance(-1.0,-1.0);
tx.translate(-iW, -iH);
//tx.scale(0.8,0.8);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
BufferedImage imgUSD = op.filter(imgREG, null);
// write flipped image to a file
File fUSD = new File("images\\USD_image.tmp");
ImageIO.write(imgUSD,"jpg",fUSD);
catch (Exception e) {
e.printStackTrace();
If I use this in a stand alone Java app it works fine but it will not work from the JSP page....
I have updated my server.policy file to give /images directory read, write, delete priviledges and I tried all the variations of the path (relative, absolute, direct....)...
I get the following error from the server log:
[#|2004-05-17T13:47:56.173-0400|WARNING|sun-appserver-pe8.0|javax.enterprise.system.stream.err|_ThreadID=11;|
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(ImageIO.java:1263)
at org.apache.jsp.ecards.mailcard_jsp._jspService(mailcard_jsp.java:125)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:141)
Can someone tell me what am I missing....
My JSP page is mailcard.jsp and images are under it in the images subdirectory....
Thanks
Amir

Hi,
Replace the following lines:
try{
String imgPath = "\\images\\AINCC.gif";
with
<%String contextPath = request.getContextPath();%>
try{
String imgPath = <%=contextPath%> + "\\images\\AINCC.gif";
You may also need to set the web application context root.
Regards,
bazooka.

Similar Messages

  • How to use connection pooling in jsp?

    I'm new to world of JSP. I'm developing web application using Oracle 8i and JSP to implement it. I'm using jakarta-tomcat server for this purpose.
    I'll frequently access the database. so I want to use the connection pooling.
    Can anybody explain the simple procedure to use it
    thanx

    Hello syyuen,
    Please help me, here iam sending u my server.xml , web.xml and servlet
    application. I put classes12.jar in tomcat/common/lib. and above servlet
    class application under tomcat/webapps/root/web-inf/classes
    and this is a simple servlet program for getting connection from the
    connection pool of tomcat using tyrex..
    my oracle database name is "myuser" and password is "mypass"
    either u check my server.xml or tell me where under which tag should i
    place <Resource...> tag in server.xml and should i need to modify any
    other places..??
    server.xml
    <Server port="8005" shutdown="SHUTDOWN" debug="0">
              <!-- Tomcat Stand-Alone Service -->
    <Service name="Tomcat-Standalone">
         <!-- Non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector className="org.apache.catalina.connector.http.HttpConnector"
    port="8080" minProcessors="5" maxProcessors="75"
    enableLookups="true" redirectPort="8443"
    acceptCount="10" debug="0" connectionTimeout="60000"/>
              <!-- AJP 1.3 Connector on port 8009 -->
    <Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
    port="8009" minProcessors="5" maxProcessors="75"
    acceptCount="10" debug="0"/>
              <!-- Top level container in our container hierarchy -->
    <Engine name="Standalone" defaultHost="localhost" debug="0">
         <!-- Global logger unless overridden at lower levels -->
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="catalina_log." suffix=".txt"
    timestamp="true"/>
         <!-- Because this Realm is here, an instance will be shared globally
              <Realm className="org.apache.catalina.realm.MemoryRealm" /> -->
                   <!-- Replace the above Realm with one of the following to get a Realm
                   stored in a database and accessed via JDBC -->
                   <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                        driverName="org.gjt.mm.mysql.Driver"
                        connectionURL="jdbc:mysql://localhost/authority?user=test;password=test"
                        userTable="users" userNameCol="user_name" userCredCol="user_pass"
                        userRoleTable="user_roles" roleNameCol="role_name" />
                   -->
    <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
              driverName="oracle.jdbc.driver.OracleDriver"
                   connectionURL="jdbc:oracle:thin:@oracle:1521:ORCL"
    connectionName = "mail"
    connectionPassword = "mail"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
                   userRoleTable="user_roles" roleNameCol="role_name" />
                        <!-- <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
                        driverName="sun.jdbc.odbc.JdbcOdbcDriver"
                        connectionURL="jdbc:odbc:CATALINA"
                        userTable="users" userNameCol="user_name" userCredCol="user_pass"
                        userRoleTable="user_roles" roleNameCol="role_name" />
                        -->
                   <!-- Define the default virtual host -->
    <Host name="localhost" debug="1" appBase="webapps" unpackWARs="true">
         <Valve className="org.apache.catalina.valves.AccessLogValve"
         directory="logs" prefix="localhost_access_log." suffix=".txt"
         pattern="common"/>
    <Logger className="org.apache.catalina.logger.FileLogger"
    directory="logs" prefix="localhost_log." suffix=".txt"
         timestamp="true"/>
                   <!-- Tomcat Root Context -->
                   <!-- <Context path="" docBase="ROOT" debug="0"/> -->
                   <!-- Tomcat Manager Context -->
    <Context path="/manager" docBase="manager" debug="0" privileged="true"/>
    <!-- MY CONTEXT HERE -->
         <Context path="/localhost" docBase="localhost" debug="0" reloadable="false" override="true">
              <Resource name="jdbc/myConnection" auth="SERVLET" type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/myConnection">
                   <parameter><name>user</name><value>myuser</value></parameter>
                   <parameter><name>password</name><value>mypass</value></parameter>
                   <parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
                   <parameter>
                        <name>url</name>
                        <value>jdbc:oracle:thin:@oracle:1521:ORCL</value>
                   </parameter>
                   <parameter>
                        <name>maxActive</name>
                        <value>32</value>
                   </parameter>
                   <parameter>
                        <name>maxIdle</name>
                        <value>10</value>
                   </parameter>
              </ResourceParams>
    <!-- END OF MY Context, Oracle username=myuser,password=mypass -->
    <!-- i pasted this context from somebody . should i need whole context or resource name in that...???? -->
    <!-- Tomcat Examples Context
    <Context path="/examples" docBase="examples" debug="0" reloadable="true" crossContext="true">
    -->
    <!--
    <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_examples_log." suffix=".txt" timestamp="true"/>
         <Ejb name="ejb/EmplRecord" type="Entity" home="com.wombat.empl.EmployeeRecordHome" remote="com.wombat.empl.EmployeeRecord"/>
    <Environment name="maxExemptions" type="java.lang.Integer" value="15"/>
    <Parameter name="context.param.name" value="context.param.value" override="false"/>
    <Resource name="jdbc/EmployeeAppDb" auth="SERVLET" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/EmployeeAppDb">
    <parameter><name>user</name><value>sa</value></parameter>
    <parameter><name>password</name><value></value></parameter>
    <parameter><name>driverClassName</name><value>org.hsql.jdbcDriver</value></parameter>
    <parameter><name>driverName</name><value>jdbc:HypersonicSQL:database</value></parameter>
    </ResourceParams>
    <Resource name="mail/Session" auth="Container" type="javax.mail.Session"/>
    <ResourceParams name="mail/Session">
    <parameter>
    <name>mail.smtp.host</name>
    <value>localhost</value>
    </parameter>
    </ResourceParams>
    -->
    </Context>
    </Host>
    </Engine>
    </Service>
         <!-- Define an Apache-Connector Service -->
    <Service name="Tomcat-Apache">
    <Connector className="org.apache.catalina.connector.warp.WarpConnector"
    port="8008" minProcessors="5" maxProcessors="75"
    enableLookups="true" appBase="webapps"
    acceptCount="10" debug="0"/>
                   <!-- Replace "localhost" with what your Apache "ServerName" is set to -->
    <Engine className="org.apache.catalina.connector.warp.WarpEngine"
    name="Apache" debug="0">
                   <!-- Global logger unless overridden at lower levels -->
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="apache_log." suffix=".txt"
    timestamp="true"/>
                   <!-- Because this Realm is here, an instance will be shared globally -->
    <Realm className="org.apache.catalina.realm.MemoryRealm" />
    </Engine>
    </Service>
    </Server>
    web.xml
    <web-app>
    <servlet>
    <servlet-name>conServlet</servlet-name>
    <servlet-class>conServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>conServlet</servlet-name>
    <url-pattern> /conServlet </url-pattern>
    </servlet-mapping>
    <resource-ref>
    <description> Resource reference to java.sql.Connection
    factory defined in server.xml
    </description>
    <res-ref-name>jdbc/myConnection</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    servlet application
    DataSource ds = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/myConnection");
    conn = ds.getConnection();
    out.println("conn : " + conn);

  • How use class file in jsp(very urgent)

    i have class file called birds (birds is actually a xslt file transformed to java class file) now this class file i have to use in my jsp file. how can i use them. if possible can any one give me sample code please very urgent
    can any one help me

    java files
    import org.w3c.dom.*;
    import javax.servlet.http.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import java.io.*;
    public class XmlParser
         public String XmlParser()
              try
    String strXML= "employee.xml";
                   String xslFile = "employeeId.xsl";
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   StreamResult theTransformationResult = new StreamResult( new ByteArrayOutputStream() );
                   Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
                   transformer.transform(new StreamSource(new StringReader(strXML)), theTransformationResult);
                   String output = theTransformationResult.getOutputStream().toString()
              catch(Exception e)
                   System.out.println(" ***** XmlParser.XmlParser ERROR ***** " + e);
    return output;
    using class files in jsp
    <%@ page import="com.qqqq.aaaa.XmlParser"%>
    <%
         XmlParser xmlParser          =     new XmlParser();
    out.println(xmlParser.XmlParser());
    %>
    i think it will help you.

  • Using JNI with weblogic JSP & Servlets

    I want to use native libraries from JSP and Servlets.
              Everything works fine befire redeploying.
              After redeploying there is an error:
              Servlet failed with Exception
              java.lang.UnsatisfiedLinkError: Native Library D:\WINNT\system32\XXXX.dll
              already loaded in another classloader
              at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
              at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
              at java.lang.Runtime.loadLibrary0(Runtime.java:749)
              at java.lang.System.loadLibrary(System.java:820)
              at HelloWorld.<clinit>(HelloWorld.java:9)
              at NativeTestServlet.doGet(NativeTestServlet.java:31)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              :208)
              at
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
              ntext.java:1127)
              at
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
              :1529)
              at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >
              Can anybody solve it?
              Best wishes, Oleg.
              

    Java will not allow us to reload any class that is dependent on a native
              library. I suggest that any classes that depend on native code should be
              put in the system classpath. If you change these classes or the native
              library you will need to restart your server.
              Sam
              "Jennifer Yin" <[email protected]> wrote in message
              news:[email protected]...
              > Oleg-
              >
              > I'm having the exact same problem and was wondering how you fixed it. I
              ran
              > javah -jni <classname> to verify the correct method call and have also
              verified
              > that the library file is included in the system path.
              >
              > Any other suggestions?
              >
              > Jennifer
              >
              > Oleg wrote:
              >
              > > I want to use native libraries from JSP and Servlets.
              > > Everything works fine befire redeploying.
              > > After redeploying there is an error:
              > >
              > > Servlet failed with Exception
              > > java.lang.UnsatisfiedLinkError: Native Library
              D:\WINNT\system32\XXXX.dll
              > > already loaded in another classloader
              > > at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1346)
              > > at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1306)
              > > at java.lang.Runtime.loadLibrary0(Runtime.java:749)
              > > at java.lang.System.loadLibrary(System.java:820)
              > > at HelloWorld.<clinit>(HelloWorld.java:9)
              > > at NativeTestServlet.doGet(NativeTestServlet.java:31)
              > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
              > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
              > > at
              > >
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              > > :208)
              > > at
              > >
              weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
              > > ntext.java:1127)
              > > at
              > >
              weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
              > > :1529)
              > > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
              > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              > > >
              > >
              > > Can anybody solve it?
              > >
              > > Best wishes, Oleg.
              >
              

  • Using java bean with jsp

    hello friends,
    i'm new to jsp. i want to create an html form that accepts username and a value from four radio buttons and display back the entered name and checked radio button's value using java bean.
    i use the <jsp:setProperty id="" property="*"> method. i don't know how to access the radio buttons value from the html.
    also when i use an additional field other than username the jsp page is showing error.
    Please give me the correct method to use java bean with jsp in this circumstance.
    thank you.

    thank you, but i have a problem left. the case is like this.
    i got the jsp and bean worked fine when i have a sinle input text field.
    but when i added a second text field i recieved the following error.
    javax.servlet.ServletException: basket.newbean.getUserPass()Ljava/lang/String;
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
         org.apache.jsp.newform.process_jsp._jspService(process_jsp.java:69)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    where userPass is the new form element. I have made the subsequent chanes in my bean program and jsp file.
    pls hlp.

  • ImageIO - javax.imageio.IIOException: Can't get input stream from URL

    Hi,
    I'm developing a program which accesses a given URL of an image and saves it to a file. However when I try this I get the following error:
    javax.imageio.IIOException: Can't get input stream from URL!
         at javax.imageio.ImageIO.read(Unknown Source)
         at ImageSave.main(ImageSave.java:12)
    Caused by: java.net.ConnectException: Connection timed out: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at sun.net.NetworkClient.doConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at java.net.URL.openStream(Unknown Source)
         ... 2 moreThe internet connection I am using uses a proxy server and I think this is where the problem lies. I'm using Eclipse version 3.3 and I've tried changing the network settings to use the proxy's hostname and port but this still isn't working. I've also tried using System.setProperty("http.proxyHost", "hostname") and System.setProperty("http.proxyPort", "port") but that hasn't worked for me either. Below is my class in full.
    import java.awt.image.*;
    import javax.imageio.*;
    import java.io.*;
    import java.net.*;
    public class ImageSave
         public static void main(String args[])
              try {
                   URL url = new URL("http://www.example.com/image.jpg");
                   BufferedImage image = ImageIO.read(url);
                   ImageIO.write(image, "JPG", new File("image.jpg"));
              catch (Exception e) {
                   e.printStackTrace();
    }The error occurs with the line: BufferedImage image = ImageIO.read(url);
    I have tried looking for a way to change how this specific method accesses the internet (e.g: a Proxy parameter with URLConnection) but there doesn't seem to be any.
    Any help or suggestions would be greatly appreciated.
    -Robert

    Ah, that worked fine. I had thought of using that earlier but I was under the impression that the input stream would be HTML rather than an actual image. Not sure why.. Anyway, thanks very much for your help!
    Here is the new code with your suggested revisions and a URLConnection to get the input stream:
    import java.awt.image.*;
    import javax.imageio.*;
    import java.io.*;
    import java.net.*;
    public class ImageSave
        public static void main(String args[])
            try {
                 // This is where you'd define the proxy's host name and port.
                 SocketAddress address = new InetSocketAddress(hostName, port);
                 // Create an HTTP Proxy using the above SocketAddress.
                 Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
                 URL url = new URL("www.example.com/image.jpg");
                 // Open a connection to the URL using the proxy information.
                 URLConnection conn = url.openConnection(proxy);
                 InputStream inStream = conn.getInputStream();
                 // BufferedImage image = ImageIO.read(url);
                 // Use the InputStream flavor of ImageIO.read() instead.
                 BufferedImage image = ImageIO.read(inStream);
                 ImageIO.write(image, "JPG", new File("image.jpg"));
            catch (Exception e) {
                 e.printStackTrace();
    }Edited by: Ragnarob on Apr 21, 2009 2:49 AM

  • Weblogic.utils.NestedRuntimeException when using javax.servlet.Filter

    IDE: JDev 10gR3.4 & JDev 11gR2.3
    ViewController technology: JSF/ADF Faces
    Example code flow:
    Run page2.jsf
    MyFilter intercepts request, checks for parameter on session.
    If parameter not null, goto page2.jsf
    Else redirect to page1.jsf
    page1.jsf has a button that sets the value on the session scope after clicking.
    In jdev 11gR2.3, I get an weblogic.utils.NestedRuntimeException after clicking the button on page1.jsf. This error does not occur in jdev 10gR3.5. Although the application continues to execute and proper info is displayed, I’m wondering why this occurs and also if I should be concerned. Has anyone experienced a similar issue when using javax.servlet.Filter in 11g?
    MyFilter code snipet:
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
            try {
                HttpServletRequest httpRequest = (HttpServletRequest)servletRequest;
                HttpServletResponse httpResponse = (HttpServletResponse)servletResponse;
                String redirect = httpRequest.getContextPath() + "/faces/page1.jsf"; //only difference here is 11g uses jsf, 10g uses jsp.
                String uri = httpRequest.getRequestURI().toString();
                Boolean mySessionAttribute = (Boolean)httpRequest.getSession().getAttribute("MYSESSIONATTRIBUTE");
                if (uri.endsWith(redirect) || mySessionAttribute != null) {
                    filterChain.doFilter(servletRequest, servletResponse);
                } else {
                    httpResponse.sendRedirect(redirect);
                    return;
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ServletException e) {
                e.printStackTrace();
    page1.jsf/jsp
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
        <h:form id="f1">
            <h:commandButton value="Submit" id="cb1" action="#{Page1Bean.clicked}" type="submit"/>
        </h:form>
    </f:view>page2.jsf/jsp
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
        <af:document title="main.jsf" id="d1">
            <af:form id="f1">
                <af:outputText value="This is the main content" id="ot1"/>
            </af:form>
        </af:document>
    </f:view>Page1Bean.java
    public class Page1Bean {
        public void clicked() {       
            FacesContext context = FacesContext.getCurrentInstance();
            ExternalContext externalContext = context.getExternalContext();
            externalContext.getSessionMap().put("MYSESSIONATTRIBUTE", Boolean.TRUE);
            try {
                externalContext.redirect("/11gFilterExample-ViewController-context-root/faces/page2.jsf");
            } catch (IOException e) {
                    e.printStackTrace();
    }Full exception
    weblogic.utils.NestedRuntimeException: Cannot parse POST parameters of request: '/11gFilterExample-ViewController-context-root/faces/page1.jsf'
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:2144)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.parseQueryParams(ServletRequestImpl.java:2024)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.getQueryParams(ServletRequestImpl.java:1918)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.getParameter(ServletRequestImpl.java:1995)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.access$800(ServletRequestImpl.java:1817)
         at weblogic.servlet.internal.ServletRequestImpl.getParameter(ServletRequestImpl.java:804)
         at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:169)
         at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:43)
         at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:31)
         at org.apache.myfaces.trinidadinternal.context.external.AbstractAttributeMap.get(AbstractAttributeMap.java:73)
         at oracle.adfinternal.controller.state.ControllerState.getRootViewPortFromRequest(ControllerState.java:788)
         at oracle.adfinternal.controller.state.AdfcContext.initialize(AdfcContext.java:185)
         at oracle.adfinternal.controller.state.AdfcContext.initialize(AdfcContext.java:79)
         at oracle.adfinternal.controller.application.AdfcConfigurator.beginRequest(AdfcConfigurator.java:53)
         at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._startConfiguratorServiceRequest(GlobalConfiguratorImpl.java:562)
         at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl.beginRequest(GlobalConfiguratorImpl.java:212)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:174)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.net.SocketException: Connection reset
         at java.net.SocketInputStream.read(SocketInputStream.java:168)
         at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:177)
         at weblogic.servlet.internal.ServletInputStreamImpl.read(ServletInputStreamImpl.java:228)
         at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:2118)
         ... 39 more
    <UIXEditableValue> <_isBeanValidationAvailable> A Bean Validation provider is not present, therefore bean validation is disabled

    I dont believe that solution pertains to my case. clicked() is invoked from standard jsf page and the adf controller is not acquired yet. i put a couple of print statements in the filter and it seems that the doFilter is called twice! This is not the case when running in 10g.
                if (uri.endsWith(redirect) || mySessionAttribute != null) {
                    System.out.println("URI dofilter: "+uri);
                    filterChain.doFilter(servletRequest, servletResponse);
                } else {
                    System.out.println("URI sendRedirect: "+uri);
                    httpResponse.sendRedirect(redirect);              
                }11g weblogic console log:
    URI sendRedirect: /11gFilterExample-ViewController-context-root/faces/page2
    URI dofilter: /11gFilterExample-ViewController-context-root/faces/page1.jsf
    URI dofilter: /11gFilterExample-ViewController-context-root/faces/page1.jsf
    10g oc4j console log:
    13/01/07 15:48:13 URI sendRedirect: /10gFilterExample-ViewController-context-root/faces/page2.jsp
    13/01/07 15:48:13 URI dofilter: /10gFilterExample-ViewController-context-root/faces/page1.jsp
    I believe whatever thats causing this occur could be why the exception is thrown...

  • Problems with javax.imageio.ImageIO (cannot be resolved) *Urgent*

    I was trying to import javax.imageio.ImageIO into my project but it cannot work... I am using Websphere Application 5.1.2 and using JDK 1.4.2_07... I try to import external jar containing javax.image but it still can't solve my problem... So can anyone help me... Thank alot...

    There is no exception, the javax.imageio.ImageIO.read(InputStream input) method simply returns null, indicating that the stream can't be decoded with any of the registered ImageReaders.
    BufferedImage bi = javax.imageio.ImageIO.read(new ByteArrayInputStream(wr2.getData()))
    wr2 is of a class that I have written myself, and the method getData() returns a byte[] array consisting of the bytes previously read from the .gif-file...
    there is nothing wrong with the data stored in the byte[] array, I have even compared it to the original file byte by byte... and it's all the same.
    this works though:
    BufferedImage bi = javax.imageio.ImageIO.read(new FileInputStream("img/iconOnlineDark.gif"))
    Strange problem, in my opinion... but I'm not an expert in streams... so it might not be as strange as it seems to me...? Anyway, I must find a solution to this.
    /erik

  • Javax.Imageio Help Needed!

    Basically, I found a site with a Javax.Imageio applet used to take screenshots with the click of a button.
    The problem is that I know nothing about compiling Java, and I would like some assistance. This applet is a necessary addition to a webpage gaming site browser (Basically it's a framed page which goes to the different game's servers to play the game) so that the users can easily take screenshots of what's happening in the game.
    The example script they have is located at:
    http://schmidt.devlib.org/java/save-screenshot.html
    But I need it to be compiled and changed a bit... The output only allows output of one file, which isn't good... It saves as out.png, and rewrites over it if you go to take a 2nd screenshot. The problem with this is that many users will need to take multiple screenshots. I need this example applet changed to do something like "screen1.png" then "screen2.png" then "screen3.png", and so on... If possible, I'd like it to save to Desktop/Screenshots/screen(x).png
    Could I get a bit of assistance?
    Thanks a lot, I appreciate any help I could get VERY much.
    Please post the finished applet if you're able to help as a response to here, preferably in the format of a zip or rar with the files inside.

    But I need it to be compiled and changed a bit... The output only allows output of one file, which isn't good...
    It saves as out.png, and rewrites over it if you go to take a 2nd screenshot.
    The problem with this is that many users will need to take multiple screenshots.
    I need this example applet changed to do something like "screen1.png" then "screen2.png" then "screen3.png", and so on...
    If possible, I'd like it to save to Desktop/Screenshots/screen(x).pngDid you even read the documentation on that web page, or the source code itself? From the statements you made, it would appear that you didn't read it very closely. If that directory already exists (Desktop/Screenshots), you don't have to change the code to save files as you want them (it won't auto-increment the number, though--auto-incrementing would require a change).
    When you have downloaded and installed the Java SDK, re-read the web page, and give the program a shot.

  • Can't find default package `javax.imageio' error

    We are running jdk "1.4.2_05-b04" on linux. And I have a simple program that is importing package javax.imageio. But the compiler is not finding it. Now since this is a j2ee envrionment I am using ANT to compile. Here is the error I am getting:
    --- BEGIN ERROR TEXT---- [javac] /home/sroshan/samcvs/psimc/src/com/psi/psimc/tasks/servlets/StockGraphProducer.java:28:
    error: Can't find default package `javax.imageio'.
    Check the CLASSPATH environment variable and the access to the archives
    [javac] 1 error
    --- END ERROR TEXT----
    Here are my questions:
    1-Any one has any idea why this package may be in a special location in my jdk path that ANT can not find?
    2- What jar file would be containing the javax.imageio package?
    Since at list I could see if that jar may be included into my ANT classpath or not.
    Any help is appreciated
    Regards
    Siamak

    Hi,
    hey..I am also getting the same error. Please let me know what do you mean by path was so long??
    Are you talking about system Path variable or the installation path?I believe there is no restriction on the system path length, just search for cl.exe and make sure it is included in the system PATH.
    Regards,
    Hussein

  • Javax.imageio.IIOException: Insufficient memory (case 2)         at com.sun

    javax.imageio.IIOException: Insufficient memory (case 2)
    at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(J[BIII[IIIIII[Ljavax.imageio.plugins.jpeg.JPEGQTable;Z[Ljavax.imageio.plugins.jpeg.JPEGHuffmanTable;[Ljavax.imageio.plugins.jpeg.JPEGHuffmanTable;ZZZI[I[I[I[I[IZI)Z(Native Method)
            at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:971)
            at javax.imageio.ImageWriter.write(ImageWriter.java:598)
            at javax.imageio.ImageIO.write(ImageIO.java:1450)
            at javax.imageio.ImageIO.write(ImageIO.java:1515)
            at jsp_servlet._css.__code._jspService(__code.java:145)
            at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
            at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:225)
            at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:127)
            at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:230)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    <img border=0 src="code.jsp">
    the content of JSP file about:
    <%@ page import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*"%>
    <%@ page import="java.io.OutputStream"%>
    <%@ page pageEncoding="UTF-8"%>
    <%!Color getRandColor(int fc, int bc) {   
    Random random = new Random();
    if (fc > 255)
    fc = 255;
    if (bc > 255)
    bc = 255;
    int r = fc + random.nextInt(bc - fc);
    int g = fc + random.nextInt(bc - fc);
    int b = fc + random.nextInt(bc - fc);
    return new Color(r, g, b);
    %>
    <%
    try {  
    out.clearBuffer(); // 加上这一句
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    int width = 70, height = 20;
    BufferedImage image = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
    OutputStream os = response.getOutputStream();
    Graphics g = image.getGraphics();
    Random random = new Random();
    //设置背景和大小
    g.setColor(getRandColor(200, 250));
    g.fillRect(0, 0, width, height);
    //设置字体和颜色
    g.setFont(new Font("Times New Roman", Font.BOLD, 20));
    g.setColor(getRandColor(120, 200));
    for (int i = 0; i < 50; i++) {   
    int x = random.nextInt(width);
    int y = random.nextInt(height);
    int xl = random.nextInt(5);
    int yl = random.nextInt(5);
    g.drawLine(x, y, x + xl, y + yl);
    String sRand = "";
    for (int i = 0; i < 4; i++) {
    String chose="0123456789";
    String rand = String.valueOf(chose.charAt(random.nextInt(chose.length())));
    sRand += rand;
    g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
    g.drawString(rand, 15 * i + 6, 16);
    session.setAttribute("rand", new String(sRand));
    g.dispose();
    g=null;
    ImageIO.write(image, "JPEG", os);
    os.flush();
    os.close();
    os = null;
    response.flushBuffer();
    out.clear();
    out = pageContext.pushBody();
    } catch (IllegalStateException e) {   
    System.out.println(e.getMessage());
    e.printStackTrace();
    %>

  • Javax.imageio.ImageIO: LUT has improper length!

    I have a problem similar to those described in these forum postings:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=404731
    and
    http://forum.java.sun.com/thread.jspa?forumID=256&threadID=510170
    I use the following code:
    String imageURL = "http://a-valid-url";
    java.net.URL url = new java.net.URL(imageURL);
    javax.imageio.stream.ImageInputStream iis =
    javax.imageio.ImageIO.createImageInputStream(url.openStream());
    java.awt.Image img = javax.imageio.ImageIO.read(iis);
    The server at the end of the URL sends back an image in PNG format. The code works fine except on the rare occasions that the image is only black and white, when our old friend the java.lang.IllegalArgumentException is thrown with the message "LUT has improper length!". (I think the exclamation mark on the end is a nice touch.)
    I understand from the other postings that this is a shortcoming in the class I am using. Does anyone know of a way to work around it?
    Thanks in advance!

    I have a problem similar to those described in these forum postings:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=404731
    and
    http://forum.java.sun.com/thread.jspa?forumID=256&threadID=510170
    I use the following code:
    String imageURL = "http://a-valid-url";
    java.net.URL url = new java.net.URL(imageURL);
    javax.imageio.stream.ImageInputStream iis =
    javax.imageio.ImageIO.createImageInputStream(url.openStream());
    java.awt.Image img = javax.imageio.ImageIO.read(iis);
    The server at the end of the URL sends back an image in PNG format. The code works fine except on the rare occasions that the image is only black and white, when our old friend the java.lang.IllegalArgumentException is thrown with the message "LUT has improper length!". (I think the exclamation mark on the end is a nice touch.)
    I understand from the other postings that this is a shortcoming in the class I am using. Does anyone know of a way to work around it?
    Thanks in advance!

  • How can I print a html Using javax.print

    Hi friends,
    I am in big trouble . I use following code to print a html file using javax.print api.
    import java.io.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.print.event.*;
    public class PrintPS
         public static void main(String args[]) {
              PrintPS html = new PrintPS();
         public PrintPS() {
         DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_HTML_HOST;
         PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
         aset.add(MediaSizeName.ISO_A4);
         aset.add(new Copies(1));
         aset.add(MediaTray.MAIN);
         PrintService pservices = PrintServiceLookup.lookupDefaultPrintService();
         if(pservices==null)
              System.out.println(" printer not found");
         if (pservices!= null) {
         System.out.println("selected printer " + pservices.getName());
         DocPrintJob pj = pservices.createPrintJob();
         try {
         InputStream fis = new FileInputStream("abc.html");
         Doc doc = new SimpleDoc(fis, flavor, null);
    System.out.println("printing started ");
         pj.print(doc, aset);
    System.out.println("printing completed");
         } catch (IOException ie) {
         System.err.println(ie);
         } catch (PrintException e) {
         System.err.println(e);
    This code gives me "sun.print.PrintJobFlavorException: invalid flavor"
    So i use all four TEXT_HTML flavor but i do not find the solution.
    I am able to print pdf, jpg, gif files but i can not able to print txt and html file.
    My printer supports txt and html printing becaue i do printing directolly by browser's or notpad's print command .

    Hi friends,
    I am in big trouble . I use following code to print a
    html file using javax.print api.Use Code Tags
    http://forum.java.sun.com/help.jspa?sec=formatting
    My printer supports txt and html printing becaue i do
    printing directolly by browser's or notpad's print
    command .Notepad & your browser prob. convert to the HTML/text(1) into the printers native format.
    1) I am suprised that it does not print text.

  • How to use mxml in a jsp file?

    I'm trying to use flex in a .jsp file. I followed the
    suggestion that I use the Flex 2 Tag library as suggested by this
    link:
    http://labs.adobe.com/wiki/index.php/Flex_2_Tag_Library_for_JSP#Download_and_Installation
    but I couldn't find it. I also downloaded LiveCycle Data Services
    ES but couldn't find the flex-bootstrap.jar.
    I have a simple example:
    <!--<%@ taglib uri="FlexTagLib" prefix="mm" %>-->
    Use the <mxml> tag to insert a Flex application in an
    existing JSP page. The following example shows the <mxml> tag
    with the source attribute to include an external MXML file:
    <mm:mxml source="CustomerServiceChat.mxml"/>
    Alternatively, you can use the <mxml> tag with inline
    MXML source code, as the following example shows:
    <mm:mxml>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns="*">
    <mx:Text label="Hello World">
    </mx:Application>
    </mm:mxml>
    I also added the following code in my web.xml:
    <taglib>
    <taglib-uri>FlexTagLib</taglib-uri>
    <taglib-location>/WEB-INF/lib/flex-bootstrap.jar</taglib-location>
    </taglib>
    and obviously I get an error because I don't have the
    flex-bootstrap.jar file. Please let me know how this can be
    corrected. Thanks in advance!

    Adobe Newsbot hopes that the following resources helps you.
    NewsBot is experimental and any feedback (reply to this post) on
    its utility will be appreciated:
    Adobe - Developer Center : Flex quick start guide for PHP
    developers:
    Apr 30, 2007 ... In this example, I changed the result data
    type to XML with E4X support by setting .... In Flex you would
    download a file using this code:
    Link:
    http://www.adobe.com/devnet/flex/articles/php_getstarted.html
    2d. Tutorial - Flex 3 Getting Started - Adobe Learning
    Resources:
    See Calling XML Web Services over the Web Using the Web
    Service References ... For information on integrating PHP and Flex
    using AMF to encode the data,
    Link:
    http://learn.adobe.com/wiki/display/Flex/2d.+Tutorial
    Mike Potter: Flex and PHP - A simple sample:
    I have other example with PHP and MySql and give the same
    error, and a example .... Flex Data Services... I choose None (???)
    because I work with php and
    Link:
    http://blogs.adobe.com/mikepotter/2006/02/flex_and_php_a_1.html
    Adobe - Developer Center : Transmitting data between Flex and
    PHP:
    Sep 4, 2007 ... Now that the user interface is set up and
    ready to go you can add the HTTP services to go ask for the data
    from the PHP code. In Flex you
    Link:
    http://www.adobe.com/devnet/flex/articles/flex_php_json.html
    Integrating Adobe Flex and PHP:
    Mar 1, 2006 ... The first step is to download Flex Builder
    2.0 from the Adobe labs ... For example, you could use this same
    PHP script to pass data to a
    Link:
    http://devzone.zend.com/article/11-Integrating-Adobe-Flex-and-PHP
    Disclaimer: This response is generated automatically by the
    Adobe NewsBot based on Adobe
    Community
    Engine.

  • Error when using javax.script package

    Hi
    I want to call a javascript method from a .js file from .java class.
    when i searched, i came to understand that using jdk1.6 i can use javax.script package tht provide me what i needed.
    using the reply i got from i earlier post, i tried one example.
    public void show() {
    ScriptEngineManager engineMgr = new ScriptEngineManager();
    ScriptEngine engine= engineMgr.getEngineByName("JavaScript");
    try {
    engine.eval(new FileReader("D:/ShowScript.js"));
    Invocable invocableEngine = (Invocable) engine;
    //show_message is my function in ShowScript.js file
    invocableEngine.invokeFunction("show_message",null);
    } catch (Exception e) {
    e.printStackTrace();
    ShowScript.js
    function show_message()
    println("===> hi");
    alert("hi");
    When i execute my program, im getting the following error
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "alert" is not defined. ( #8) in at line number 8
    at com.sun.script.javascript.RhinoScriptEngine.invoke(RhinoScriptEngine.java:184)
    at com.sun.script.javascript.RhinoScriptEngine.invokeFunction(RhinoScriptEngine.java:142)
    at testbuiltin.backing.Show_alert.show(Show_alert.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
    When i remove the alert() from the js file, the println is working. But what i neede is the alert.
    Can anyone plz help me to solve this problem.

    As you're talking about "backing beans", are you using JSF?
    After all, this is definitely not the way to let Java and JS interact with each other. Java runs at the server side. JS runs at the client side. Java can write JS code to the response, but definitely cannot call it. JS can access the HTML DOM and invoke requests to the server (form.submit() and AJAX and so on) and send parameters along the request, but definitely cannot call Java classes and methods independently. Nothing more and nothing less than that.

Maybe you are looking for

  • Text messages not sending

    Hey, A few weeks ago i bought some skype credit to text my girlfriend in Peru, from the UK (england). For the first week or so it worked fine, she would recieve the message very quickly, and the price was very reasonable. No problems. But, suddenly i

  • Installed new Hard Drive in iMac G3, can't get OSX to install

    I installed a new 40GB drive in my iMac G3 333Mhz Tray Loader, I used the Disk Utility to create one 37.15GB partition called "Machintosh HD". When I run the Mac OS X Panther installer it recognizes my partition but there is a Red Exclamation point o

  • Calendar snooze "until start" doesn't work

    I'm using Mavericks 10.9.2. If I have an event notification pop up, I can click and hold the snooze button and one of the options is "until start time".  However, selecting this causes an alert to appear at some seemingly random time *after* the star

  • After installation program does not start - DB MS Access

    Hi all, A customer had a program writen in VB6 and MS Access 97.  First I converted the database to version 2000 and than to MS Access 2013. After that I have converted the program first to VB2005 and then to VB2013 where I make all the changes. I pu

  • I would need the copy of a receipt from March 2014

    Hello, My partner bought an ipad in March and our company's accountant is asking for the receipt. I have a copy but it is unreadable (ink partially disappeared). Could you please send me another copy of the receipt? Here are the customer service pin