Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

forwarding request to a jsp from a filter and displaying image in that jsp

Ads

 
 

Share on Google+Share on Google+

suresh anugandula
forwarding request to a jsp from a filter and displaying image in that jsp
1 Answer(s)      5 years and 8 months ago
Posted in : JSP-Servlet

Hi all,

I have placed all the jsps in pages folder and images in images folder. in pages folder i placed login.jsp and in images folder i placed tatalogo3.jpg. following is login.jsp

  • login.jsp

And i am forwarding request to this login.jsp from a filter like this

request.getRequestDispatcher("login.jsp").forward(request, response);

Above line is forwarding the request to login.jsp correctly, but in login.jsp the image is not displaying. Can you help me in resolving this problem.

Thanks & Regards, Suresh

Ads
View Answers

December 7, 2011 at 1:03 PM


Jsp Display Image

<%@ page import="java.io.*" %>
<[email protected] contentType="image/gif" %><%
    OutputStream o = response.getOutputStream();
    InputStream is = new FileInputStream(new File("C:/images/image.gif"));
    byte[] buf = new byte[32 * 1024]; 
    int nRead = 0;
    while( (nRead=is.read(buf)) != -1 ) {
        o.write(buf, 0, nRead);
    }
    o.flush();
    o.close();
    return; 
%>

Ads









Related Tutorials/Questions & Answers:
forwarding request to a jsp from a filter and displaying image in that jsp
forwarding request to a jsp from a filter and displaying image in that jsp ... And i am forwarding request to this login.jsp from a filter like this request.getRequestDispatcher("login.jsp
JSP forwarding
JSP forwarding  What is JSP forwarding?   Hi, You can use the JSP forward tag for jsp forwarding. This will help you forward your request to some other page on the same server. Here is the code for jsp forwarding
Advertisements
Displaying image using jsp and spring.
Displaying image using jsp and spring.  how to display an image stored in WEB-INF/images folder on the browser using jsp and spring
forwarding request to a jsp when user clicks on back button in ie
forwarding request to a jsp when user clicks on back button in ie  Hi all, I have developed a web based application. After user log out... we forward request to a jsp page whenever user clicks on back button
Displaying image when clicked on URL in jsp - JSP-Servlet
in displaying the image from the folder. Regards, Anish...Displaying image when clicked on URL in jsp  Hi, I am using... For Screenshot : abc.jpg here abc.jpg is a url and when clicked would show me an image
displaying data retrieved from a database in a jsp page
displaying data retrieved from a database in a jsp page  the page... processRequest(HttpServletRequest request, HttpServletResponse response) throws... sql = "select billid, customerid, billdate, status from customerbills where
displaying both image and records problem in jsp and servlet - JSP-Servlet
displaying both image and records problem in jsp and servlet  hello, Thanks for your reply on the question i asked the other time. It worked perfectly, but it's still not what i want. What i want is that, i want
How to retrieve image from mysql database in JSP?
How to retrieve image from mysql database in JSP?  Hi, I need JSP... to retrieve image from mysql database in JSP? Thanks   Hi, You can write SQL query to find the data from database and get the image from resultset using
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them... Request") return } var url= "emp.jsp"; url += "?val1=" +str1+"&&val2="+str2
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them... Request") return } var url= "emp.jsp"; url += "?val1=" +str1+"&&val2="+str2
jsp programe for displaying data from database
jsp programe for displaying data from database  i am using JSP.i want.../WebSevices/19592-retriving-data-from-sql-server-using-jsp-code-and-placing-them... Request") return } var url= "emp.jsp"; url += "?val1=" +str1+"&&val2="+str2
Displaying Constant values from Interface in JSP - JSP-Servlet
Displaying Constant values from Interface in JSP  Hi, ******Sorry... need to display suitable fields in my jsp but this should be done upon suitable...="COMP100"; // and so on } IN HOME JSP ****** home.jsp **** Currently
image upload with jsp from form
image upload with jsp from form  hi i used the code specified in your following post http://www.roseindia.net/answers/viewqa/JSP-Servlet/9749-image...) org.apache.jsp.upload_jsp._jspService(upload_jsp.java:85
how to fetch image from mysql using jsp
how to fetch image from mysql using jsp  how to fetch image from mysql using jsp
How to retrieve image from database using jsp and servlet?
How to retrieve image from database using jsp and servlet?  Hi, I am trying to find code for displaying the image from database in a JSP page. How to retrieve image from database using jsp and servlet
How to store and retrieve image from database in JSP?
How to store and retrieve image from database in JSP?  Hi, In one of my application I have to store and then display the image in JSP. How to store and retrieve image from database in JSP? Thanks   HI, You can use
How to retrieve blob image from database in JSP?
How to retrieve blob image from database in JSP?  Hello, JSP is used... the blog image from database. How to retrieve blob image from database in JSP?   Hi, Please check the tutorial Retrieve image from database using
Retrview image from sqlserver2000 and display in jsp - JSP-Servlet
Retrview image from sqlserver2000 and display in jsp  How to retreview image from sqlserver2000 to jsp? pls give the solution i am using Tomcat 4... for more information, http://www.roseindia.net/jsp/ Thanks
how to add Arraylist filter for a jsp page showing results from a servlet
how to add Arraylist filter for a jsp page showing results from a servlet  hello sir/mam, in my project i have an arraylist showing results in a jsp...; and from that i want result filtered as this the table which is filter
How JSP Forwards a request
; The <jsp:forward>  forwards the request information from one resource to the other, for example, one jsp file to other. To forward a request from one... How JSP Forwards a request     
jsp request in struts1
jsp request in struts1  how the request for a JSp is processed in Struts1?Any JsP page in the end a servlet only.where is the URL pattern for this servlet
JSP Request Object
JSP Request Object  JSP Request Object ?   request object in JSP is used to get the values that the client passes to the web server during an HTTP request. The request object is used to take the value from the client?s
retrive image from database using jsp without stream
retrive image from database using jsp without stream  How to retrive image from database using jsp without stream like (inputStream
displaying List of records from database in a jsp using ajax
displaying List of records from database in a jsp using ajax  Sir, I need to retrieve the records from the database for every 7 seconds and display...;[email protected] import="com.tbss.RtChannels"%><%@ taglib uri="http://java.sun.com/jsp
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp... database. hope u can help in my database: i have imagetbl that contain image column(to store the image) as varbinary and fileimage(to store the directory
how to upload image from jsp to mssql
how to upload image from jsp to mssql  hi there!!, i'm using jsp... database. hope u can help in my database: i have imagetbl that contain image column(to store the image) as varbinary and fileimage(to store the directory
Displaying Date in jsp - JDBC
Displaying Date in jsp  I want to insert Date of birth of a person in a database.i am getting input value from HTML and i use jsp application to interact with database.My JSP code for inserting Date is below: String dateStr
Delete image from folder - JSP-Servlet
Delete image from folder  Hi Thanks Rajnikant to given me reply i am not storing my image in db just userid comming from db means my... image from ur server not from local copy. DeleteServlet.java
Displaying the values in text fields of a form from a javascript function in jsp
Displaying the values in text fields of a form from a javascript function in jsp  Hi all, I have a requirement like this, First i have to call a javascript function by passing 3 values from applet. And i have
insert and retrive image from sql server database in jsp
insert and retrive image from sql server database in jsp  what is the code to insert and retrive an image from sql server database in jsp
How Can I get ArrayList of Data from jsp with ajax request
How Can I get ArrayList of Data from jsp with ajax request  Hi, I retereved 5 Employee Record of Data from Struts Action class to jsp with ajax response. But I don't how how can reterve this dynamic 5 employee records