You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by prad <pr...@yahoo.co.in> on 2006/09/05 11:59:55 UTC
How send svg content to browser as response
Hi,
Am processing some svg files on server side and after processing i need to
send the svg as response...I set the mime type as "image/svg+xml"
and tried the below code
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println(" <head>");
out.println(" <title>SimpleServlet</title>");
out.println(" </head>");
out.println(" <body>");
out.println(" Hello, World");
out.println(" </body>");
out.println("</html>");
}
when i invoke this servlet .....it's showing download dialog box and if
press ok .....servletName.svg file gets downloads
Why its not directly displaying the contents in the browser...Any help plz..
Thanks & Regards
Prad
--
View this message in context: http://www.nabble.com/How-send-svg-content-to-browser-as-response-tf2219904.html#a6149122
Sent from the Tomcat - User forum at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How send svg content to browser as response
Posted by Giorgio Clavelli <gi...@gmail.com>.
I'm not sure if this can help, but some time ago, I played around SVG (only
with Firefox implementation) and was able, after my search homework to have
SVG content in a JSP file. If you are just mocking around and hasn't strict
requirements on using specifically servlet, then have a look at this post:
http://www.sitepoint.com/forums/showthread.php?t=368659&highlight=SVG
On 9/6/06, prad <pr...@yahoo.co.in> wrote:
>
>
> Hi ,
> Am sorry...Actually i was wrong...While posting i made a mistake
> Here it is...
> public void doGet(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException
> {
> response.setContentType("image/svg+xml");
> ServletOutputStream out = response.getOutputStream()
> out.println("<?xml version=\"1.0\"?>\n" +
> "<svg width=\"100px\"
> height=\"20px\" viewBox='0 0 400 400'>\n" +
> " <text x=\"10\" y=\"20\" >SVG
> serverside</text>\n" +
> "</svg>");
>
> out.close();
>
> }
> this is workin fine....Here am just writing out only one element as
> response
> .....I need to write whole svg file to browser...Any help
>
> Thanks & Regards
> Prad
>
>
> Markus Schönhaber wrote:
> >
> > prad wrote:
> >> Am processing some svg files on server side and after processing i need
> >> to
> >> send the svg as response...I set the mime type as "image/svg+xml"
> >> and tried the below code
> >
> > What has this servlet...
> >> public void doGet(HttpServletRequest request,
> >> HttpServletResponse response)
> >> throws ServletException, IOException{
> >>
> >> response.setContentType("text/html");
> >> PrintWriter out = response.getWriter();
> >>
> >> out.println("<html>");
> >> out.println(" <head>");
> >> out.println(" <title>SimpleServlet</title>");
> >> out.println(" </head>");
> >> out.println(" <body>");
> >> out.println(" Hello, World");
> >> out.println(" </body>");
> >> out.println("</html>");
> >> }
> > ...to do with SVG?
> >
> >> when i invoke this servlet .....it's showing download dialog box and if
> >> press ok .....servletName.svg file gets downloads
> >
> > The above servlet shows the behaviour you describe? I doubt that.
> >
> >> Why its not directly displaying the contents in the browser...Any help
> >> plz..
> >
> > You should first of all clarify what you're doing. I don't see any
> > connection
> > between the servlet code above and SVG.
> >
> > Second: Is your browser capable of rendering SVG content / has a plugin
> > installed for rendering SVG content?
> > Does
> > http://localhost:8080/jsp-examples/jsp2/jspx/textRotate.jspx?name=JSPX
> > work with your browser (assuming your Tomcat is installed on your local
> > machine and listening on port 8080)?
> >
> > Regards
> > mks
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-send-svg-content-to-browser-as-response-tf2219904.html#a6164671
> Sent from the Tomcat - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: How send svg content to browser as response
Posted by prad <pr...@yahoo.co.in>.
Hi ,
Am sorry...Actually i was wrong...While posting i made a mistake
Here it is...
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("image/svg+xml");
ServletOutputStream out = response.getOutputStream()
out.println("<?xml version=\"1.0\"?>\n" +
"<svg width=\"100px\"
height=\"20px\" viewBox='0 0 400 400'>\n" +
" <text x=\"10\" y=\"20\" >SVG
serverside</text>\n" +
"</svg>");
out.close();
}
this is workin fine....Here am just writing out only one element as response
.....I need to write whole svg file to browser...Any help
Thanks & Regards
Prad
Markus Schönhaber wrote:
>
> prad wrote:
>> Am processing some svg files on server side and after processing i need
>> to
>> send the svg as response...I set the mime type as "image/svg+xml"
>> and tried the below code
>
> What has this servlet...
>> public void doGet(HttpServletRequest request,
>> HttpServletResponse response)
>> throws ServletException, IOException{
>>
>> response.setContentType("text/html");
>> PrintWriter out = response.getWriter();
>>
>> out.println("<html>");
>> out.println(" <head>");
>> out.println(" <title>SimpleServlet</title>");
>> out.println(" </head>");
>> out.println(" <body>");
>> out.println(" Hello, World");
>> out.println(" </body>");
>> out.println("</html>");
>> }
> ...to do with SVG?
>
>> when i invoke this servlet .....it's showing download dialog box and if
>> press ok .....servletName.svg file gets downloads
>
> The above servlet shows the behaviour you describe? I doubt that.
>
>> Why its not directly displaying the contents in the browser...Any help
>> plz..
>
> You should first of all clarify what you're doing. I don't see any
> connection
> between the servlet code above and SVG.
>
> Second: Is your browser capable of rendering SVG content / has a plugin
> installed for rendering SVG content?
> Does
> http://localhost:8080/jsp-examples/jsp2/jspx/textRotate.jspx?name=JSPX
> work with your browser (assuming your Tomcat is installed on your local
> machine and listening on port 8080)?
>
> Regards
> mks
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-send-svg-content-to-browser-as-response-tf2219904.html#a6164671
Sent from the Tomcat - User forum at Nabble.com.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How send svg content to browser as response
Posted by Giorgio Clavelli <gi...@gmail.com>.
If you are targeting firefox's svg implementation. Have a read at this
first:
http://jwatt.org/svg/authoring/
On 9/5/06, Markus Schönhaber <ma...@schoenhaber.de> wrote:
>
> prad wrote:
> > Am processing some svg files on server side and after processing i need
> to
> > send the svg as response...I set the mime type as "image/svg+xml"
> > and tried the below code
>
> What has this servlet...
> > public void doGet(HttpServletRequest request,
> > HttpServletResponse response)
> > throws ServletException, IOException{
> >
> > response.setContentType("text/html");
> > PrintWriter out = response.getWriter();
> >
> > out.println("<html>");
> > out.println(" <head>");
> > out.println(" <title>SimpleServlet</title>");
> > out.println(" </head>");
> > out.println(" <body>");
> > out.println(" Hello, World");
> > out.println(" </body>");
> > out.println("</html>");
> > }
> ...to do with SVG?
>
> > when i invoke this servlet .....it's showing download dialog box and if
> > press ok .....servletName.svg file gets downloads
>
> The above servlet shows the behaviour you describe? I doubt that.
>
> > Why its not directly displaying the contents in the browser...Any help
> > plz..
>
> You should first of all clarify what you're doing. I don't see any
> connection
> between the servlet code above and SVG.
>
> Second: Is your browser capable of rendering SVG content / has a plugin
> installed for rendering SVG content?
> Does
> http://localhost:8080/jsp-examples/jsp2/jspx/textRotate.jspx?name=JSPX
> work with your browser (assuming your Tomcat is installed on your local
> machine and listening on port 8080)?
>
> Regards
> mks
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: How send svg content to browser as response
Posted by Markus Schönhaber <ma...@schoenhaber.de>.
prad wrote:
> Am processing some svg files on server side and after processing i need to
> send the svg as response...I set the mime type as "image/svg+xml"
> and tried the below code
What has this servlet...
> public void doGet(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException, IOException{
>
> response.setContentType("text/html");
> PrintWriter out = response.getWriter();
>
> out.println("<html>");
> out.println(" <head>");
> out.println(" <title>SimpleServlet</title>");
> out.println(" </head>");
> out.println(" <body>");
> out.println(" Hello, World");
> out.println(" </body>");
> out.println("</html>");
> }
...to do with SVG?
> when i invoke this servlet .....it's showing download dialog box and if
> press ok .....servletName.svg file gets downloads
The above servlet shows the behaviour you describe? I doubt that.
> Why its not directly displaying the contents in the browser...Any help
> plz..
You should first of all clarify what you're doing. I don't see any connection
between the servlet code above and SVG.
Second: Is your browser capable of rendering SVG content / has a plugin
installed for rendering SVG content?
Does
http://localhost:8080/jsp-examples/jsp2/jspx/textRotate.jspx?name=JSPX
work with your browser (assuming your Tomcat is installed on your local
machine and listening on port 8080)?
Regards
mks
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org