Using JSP object in Scriptlets
How to use a jsp object in a scriptlet?
For example i have this JSP object:
<script type="text/javascript">
var jspObject = "UserName";
</script>And i wanna use it in:
<%
String sql = "SELECT * FROM TABLENAME WHERE _USERNAME ='" + (here comes the jsp object) +"'";
db.query(sql);
%>
Hi ,
Do u want to send mails through Outlook only or u want a java smtp program to send mail that looks same as advertisment mails u get .. i e like webpage ..
Regards
Similar Messages
-
How to use jsp:scriptlet in site template
hi all,
I want to use <jsp:scriptlet> in site template, but jdev showed me an error msg when I put <jsp:scriptlet> in site template:
scriptlet can not work properly with OJSP, I checked the forums, one possible solution is to encapsulate java code in jsp taglib, but I dislike this solution.
Is there a way to disable OJSP? or any solution to use java code in site template?
Best regardsI believe the official word is if you are trying to use java code in a scriptlet in your site template then you are doing something wrong.
The goal is to keep java code separate from the template and pages. Any logic should go to your supporting serviece objects and all of your front-end work should be accomplished using available or custom tags.
Can you describe what you are trying to accomplish with this java code in your template? -
Is there a way to use bpm object in jsp (java)
hello
i could see that the bpm object can be used in jsp with javascript and fuego tag. but is there a way to use bpm object with java code?
thank you!Suppose a Servlet/JSP calls java classes. In the java
functions of those classes, is there a way to get and
set attributes with application/session scope
directly? Thanks.Only by passing a reference to those classes (or by tying in to the framework/container). -
Using Java Objects in my JSP page... objects are in a different directory
Hi,
I would like to call and use an object from a JSP page. The java object is in one directory, the jsp is in another. When I call my object, I get a JSP error that says it can't find the object and lists the directory name as part of the file.
For example, here are my two files:
/java/MyObject.class
/web/page.jsp
When I make the call to new MyObject(), I get an error message saying _web.MyObject cannot be found. Any ideas on this?
Thanks!Okay, I figured it out. In case anyone else needs it, here is what I needed to do.
1) I created my object in a package. The JSP page was looking for the object in _dir directory because a package wasn't specified. I created a subdirectory in one of the directories in my classpath and named it the same thing that the package was named.
2) Import the package
3) Make sure all methods in the classes are public, since only public methods can be accessed from outside the package.
Thanks for the help, it got me going in the right direction. -
Use javabean object from jsp file
I try to use JDBC to open database, find my record and initiate and return a static object of javabean class. In my jsp file, I try to use this object, but it is null. My directory is C:/tomcat/webapps/myapp/web-inf/classes/bean. A "jsp" folder is under "myapp" directory. I put jsp file in "jsp" and bean class in "bean".
Is there some one can give me some suggestions?
thank you!
QiangI assume that the constructor for your object is inside the static method.
If the static method returns null, then the object is not being constructed.
There is nothing wrong with the JSP.
Thus the best place to look will be inside the static method. Use tracers like System.out.println() and printStackTrace() and I am sure u will find the problem.
One thing was not very clear to me. If u construct your object within the static method, there must be some reason for that. Since you are using parameters, this does not look like a singleton. Rather I think it is one object per input combinations you have provided. It is interesting as I have never seen this kind of code before(Except session EJB) It will be a nice learning experience if you post some documents regarding your design.
Shubhrajit -
Using JSP scriplets in the JSF tags
Hi,
I haven't done that much JSP development using various tag libraries prior to looking at JSF, hence this very basic question:
I am declaring and manipulating Java variables in my JSP. Is there a way to access those in my JSF tags? It seems that something like:
<%
String myString="MyLabel";
%>
<h:view>
<h:outputText id="myID" value="<%=myString%>" />
</h:view>
blows up in the JSF processor.
I am porting some stuff to JSF and hence do not use backing beans in all cases.
Any suggestions/ideas/pointers are greatly appreciated.
Thanks in advance,
Vadim.JSF action element attributes take JSF EL expressions, not Java expressions. A JSF EL expression has access to objects in one of request, session or application scope only, not to scripting variables. One way to get your example to work is by putting the String in one of these scopes within the scriptlet, e.g.:
<%
String myString="MyLabel";
request.setAttribute("myString", myString);
%>
<h:view>
<h:outputText id="myID" value="#{myString}" />
</h:view>But, if you're porting a JSP-based application to JSF, I strongly recommend that you move all scriptlet code into beans; otherwise it's kind of pointless to migrate to JSF. The strength of JSF is its separation of UI layout and application logic.
Even though JSP happens to be one way to wire up a JSF view with JSF components, JSF has very little to do with JSP. You need to understand the basic JSF component model, event-driven development, and use JavaBeans to really gain any benefits. Don't be fooled into believing that JSF is "just a new JSP tag library" by the support for JSP as the default presentation layer; it's far more than that, and I personally believe that using JSP as the presentation layer makes using JSF a lot harder than it should be. In fact, most of the issues posted in this forum are issues with the JSP layer, not with the core JSF components or the infrastructure classes.
Hans Bergsten (EG member) -
Re: [SunONE-JATO] Re: Using an object to store and display data
Personally, I think there is little or no value to creating a "domain"
object that itself relies on a JATO QueryModel internally, but hides that
fact and requires use of BeanAdapterModel.
It would be more appropriate (and much less work, and more scalable) to just
derive a QueryModel subclass and add the domain-specific behavior to the
model. In other words, what's the point of creating an object that hides
JATO inside it when you're running in JATO to begin with? Now if the domain
object were doing plain JDBC, and thus trying to be JATO independent, that
would be different. However, you could still implement the Model interface
on the object (or use BeanAdapterModel) to integrate it seamlessly with the
View tier.
Todd
----- Original Message -----
From: "grschroeder" <grschroeder@y...>
Sent: Wednesday, July 31, 2002 12:00 PM
Subject: [SunONE-JATO] Re: Using an object to store and display data
Craig,
I think it all finally makes sense. First, your assumption is
correct regarding the process flow. The ViewBean will interact with
a custom Javabean which will then in turn interact with a SQL Model
to access the database. So now let me make sure I understand what I
need to do. Basically the custom Javabean will have a method to get
the SQLModel. I would then invoke the setValue method on the
SQLModel and call the appropriate execute method( e.g.,
executeUpdate, etc. ) just like I would do from a ViewBean. Does
this sound correct?
Thanks,
Greg
--- In SunONE-JATO@y..., "Craig V. Conover" <craig.conover@s...>
wrote:
Greg,
see below...
grschroeder wrote:
Thanks for the help Craig. I looked at the sample code that makes
use of the BeanAdapterModel. Basically it looks like it allows a
view to interact with a bean the same way it would interact with
any
other model. That part I think I understand.
This is correct.
The part I'm a little
unclear on still is how to interface this BeanAdapterModel( which
is
a very basic model ) that I now have with a query model toactually
interact with the database.
Not sure what you mean by "interface this BeanAdapterModel ... witha
query model". Does this mean that you have a ViewBean the interactswith
a custom JavaBean via the BeanAdpterModel wrapper, and from the
JavaBean you are interacting with the SQL Model?
So it looks like this: ViewBean > BeanAdapterModel(Custom JavaBean)
SQL Model > RDBMS
That's what I am reading anyway. Please explain this to me.
Would I need to make direct JDBC calls
from my custom model instead of letting JATO dynamically create
the
calls for me?
If my assumptions above are correct, then the custom JavaBean cansimply
use the SQL Model in exactly the same manner as the ViewBean,otherwise,
if no SQL Model is involved, then yes, you need to handle JDBCdirectly,
which is fine, if you do it "right" (connection pooling, result set
handling, etc.).
Thanks,
Greg
--- In SunONE-JATO@y..., "Craig V. Conover" <craig.conover@s...>
wrote:
I think the best approach would be to treat your Domain Objects
(DO) as
the Database (the enterprise tier) from JATO's perspective. You
could
create custom models that interface with our DO's and then the
JATO
Views could easily bind to the custom DO models just like anyother
model. This should eliminate the need for pushing data/objectsfrom
>
view
to model to database.
There is a JATO class called BeanAdapterModel that might be just
what
you need, however, I am not experienced with using it. Maybe
someone
else on my team or in the community could better explain how to
use
>
this
class.
craig
grschroeder wrote:
Venki,
Thanks for the response. Actually, I'm not sure if I can answer
all
of your questions because those are some of the same questions
that
we're trying to answer ourselves. Basically, what we're trying
to
>do
is incorporate our domain object model into the JATO framework.
My
thinking was that one way we could accomplish this was by
storing
>a
Javabean object in the HTTPSession to represent an object in the
domain model, and that the Viewbean and JATO Model could get and
set
data from there. If you have a better suggestion of how to
accomplish this, I'm definitely open to hearing it.
Thanks,
Greg
--- In SunONE-JATO@y..., Venki <heyvenki@y...> wrote:
OK grschroeder , first let me get this straight:
0. Are you going to pass this object to the model, or are u
going
>
to pass the session object to the model?
1. Is there any specific reason for this approach you are
taking?
2. Will there be a notification from the object u havementioned
>to
have the model persist the data?
3. What about the reverse case, when the model refreshes the
data,
how are you going to refresh you object?
4. The JavaBean Object that u are talking about, is it your own
object or is it implementation of an existing JATO interface?
~Venki
grschroeder wrote:I'm fairly new to JATO, but I think I now
have
>a
basic understanding
of how Viewbeans and Models interact. However, I want to
incorporate
the use of a Javabean object that will be stored in the HTTP
session
and will act as the connection between the Viewbean and Model
instead
of having the Viewbean and Model interact directly with each
other.
Basically I would like to have the Model set data in the object
stored in the session so that the Viewbean can pull it out to
display
it. And vice versa, once the user modifies the data and is
ready
>
to
persist it, I would like to have the Viewbean set data in the
object
stored in the session so that the Model can pull it out to
store
>it
in the database. I'm not sure what the best approach would be
to
accomplish this. Any help you could give would be greatly
appreciated.
Thanks,
Greg
To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp
Service.
Venki
IT Solutions
#6, Pycrofts Garden Road, Nugambakkam, Chennai - 600 006
91-44-4925740(Home) 91-44-8212877(Work)
* Luck is what happens when Preparation meets Opportunity.
To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp
>To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp
To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jspPersonally, I think there is little or no value to creating a "domain"
object that itself relies on a JATO QueryModel internally, but hides that
fact and requires use of BeanAdapterModel.
It would be more appropriate (and much less work, and more scalable) to just
derive a QueryModel subclass and add the domain-specific behavior to the
model. In other words, what's the point of creating an object that hides
JATO inside it when you're running in JATO to begin with? Now if the domain
object were doing plain JDBC, and thus trying to be JATO independent, that
would be different. However, you could still implement the Model interface
on the object (or use BeanAdapterModel) to integrate it seamlessly with the
View tier.
Todd
----- Original Message -----
From: "grschroeder" <grschroeder@y...>
Sent: Wednesday, July 31, 2002 12:00 PM
Subject: [SunONE-JATO] Re: Using an object to store and display data
Craig,
I think it all finally makes sense. First, your assumption is
correct regarding the process flow. The ViewBean will interact with
a custom Javabean which will then in turn interact with a SQL Model
to access the database. So now let me make sure I understand what I
need to do. Basically the custom Javabean will have a method to get
the SQLModel. I would then invoke the setValue method on the
SQLModel and call the appropriate execute method( e.g.,
executeUpdate, etc. ) just like I would do from a ViewBean. Does
this sound correct?
Thanks,
Greg
--- In SunONE-JATO@y..., "Craig V. Conover" <craig.conover@s...>
wrote:
Greg,
see below...
grschroeder wrote:
Thanks for the help Craig. I looked at the sample code that makes
use of the BeanAdapterModel. Basically it looks like it allows a
view to interact with a bean the same way it would interact with
any
other model. That part I think I understand.
This is correct.
The part I'm a little
unclear on still is how to interface this BeanAdapterModel( which
is
a very basic model ) that I now have with a query model toactually
interact with the database.
Not sure what you mean by "interface this BeanAdapterModel ... witha
query model". Does this mean that you have a ViewBean the interactswith
a custom JavaBean via the BeanAdpterModel wrapper, and from the
JavaBean you are interacting with the SQL Model?
So it looks like this: ViewBean > BeanAdapterModel(Custom JavaBean)
SQL Model > RDBMS
That's what I am reading anyway. Please explain this to me.
Would I need to make direct JDBC calls
from my custom model instead of letting JATO dynamically create
the
calls for me?
If my assumptions above are correct, then the custom JavaBean cansimply
use the SQL Model in exactly the same manner as the ViewBean,otherwise,
if no SQL Model is involved, then yes, you need to handle JDBCdirectly,
which is fine, if you do it "right" (connection pooling, result set
handling, etc.).
Thanks,
Greg
--- In SunONE-JATO@y..., "Craig V. Conover" <craig.conover@s...>
wrote:
I think the best approach would be to treat your Domain Objects
(DO) as
the Database (the enterprise tier) from JATO's perspective. You
could
create custom models that interface with our DO's and then the
JATO
Views could easily bind to the custom DO models just like anyother
model. This should eliminate the need for pushing data/objectsfrom
>
view
to model to database.
There is a JATO class called BeanAdapterModel that might be just
what
you need, however, I am not experienced with using it. Maybe
someone
else on my team or in the community could better explain how to
use
>
this
class.
craig
grschroeder wrote:
Venki,
Thanks for the response. Actually, I'm not sure if I can answer
all
of your questions because those are some of the same questions
that
we're trying to answer ourselves. Basically, what we're trying
to
>do
is incorporate our domain object model into the JATO framework.
My
thinking was that one way we could accomplish this was by
storing
>a
Javabean object in the HTTPSession to represent an object in the
domain model, and that the Viewbean and JATO Model could get and
set
data from there. If you have a better suggestion of how to
accomplish this, I'm definitely open to hearing it.
Thanks,
Greg
--- In SunONE-JATO@y..., Venki <heyvenki@y...> wrote:
OK grschroeder , first let me get this straight:
0. Are you going to pass this object to the model, or are u
going
>
to pass the session object to the model?
1. Is there any specific reason for this approach you are
taking?
2. Will there be a notification from the object u havementioned
>to
have the model persist the data?
3. What about the reverse case, when the model refreshes the
data,
how are you going to refresh you object?
4. The JavaBean Object that u are talking about, is it your own
object or is it implementation of an existing JATO interface?
~Venki
grschroeder wrote:I'm fairly new to JATO, but I think I now
have
>a
basic understanding
of how Viewbeans and Models interact. However, I want to
incorporate
the use of a Javabean object that will be stored in the HTTP
session
and will act as the connection between the Viewbean and Model
instead
of having the Viewbean and Model interact directly with each
other.
Basically I would like to have the Model set data in the object
stored in the session so that the Viewbean can pull it out to
display
it. And vice versa, once the user modifies the data and is
ready
>
to
persist it, I would like to have the Viewbean set data in the
object
stored in the session so that the Model can pull it out to
store
>it
in the database. I'm not sure what the best approach would be
to
accomplish this. Any help you could give would be greatly
appreciated.
Thanks,
Greg
To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp
Service.
Venki
IT Solutions
#6, Pycrofts Garden Road, Nugambakkam, Chennai - 600 006
91-44-4925740(Home) 91-44-8212877(Work)
* Luck is what happens when Preparation meets Opportunity.
To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp
>To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp
To download the latest version of JATO, please visit:
http://www.sun.com/software/download/developer/5102.html
For more information about JATO, please visit:
http://developer.iplanet.com/tech/appserver/framework/index.jsp -
I am trying to download a file from the server using jsp but it always shows the file in the browser.I want a Save/Open dialog box to allow the user to save this file in the local system. any feedback is welcome.
thanks in advance
vinodBasically out frame work is in struts.........
In struts for file down load I wrote the code as
String fileName = <file name>;
String filePath = <file path>;
String fileType = fileName.substring(dotIndex+1,fileName.length());
ServletOutputStream out = httpservletresponse.getOutputStream();
if (fileType.trim().equalsIgnoreCase("doc"))
httpservletresponse.setContentType( "application/msword" );
else if (fileType.trim().equalsIgnoreCase("xls"))
httpservletresponse.setContentType( "application/vnd.ms-excel" );
else if (fileType.trim().equalsIgnoreCase("pdf"))
httpservletresponse.setContentType( "application/pdf" );
else if (fileType.trim().equalsIgnoreCase("ppt"))
httpservletresponse.setContentType( "application/ppt" );
else
httpservletresponse.setContentType( "application/octet-stream" );
httpservletresponse.setHeader("Content-disposition", "attachment; filename=" +actualName );
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(filePath));
BufferedOutputStream bos = new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
bos.write(buff, 0, bytesRead);
I hav written this in seperate function which returns boolean true If this works correctly otherwise fase.
If it is 'true ' I am forwarding it to 'success.jsp' else'fail.jsp'....................
Now problem is It is not forwarding to any other pages and giving error as "Illegal state .can not forward.Response already committed."
I think this error is coming becos of 'response.setHeader()' and using out object.........
Please give me any solution for this problem.........Since I am strucked here.It is urgent for me to do...................................
I don't mind If u giv any alteernative code for this..............
Thanx in advance..................
Plz. respond quickly................... -
Which one better to use - jsp:useBean or import statement
Hi,
I just want to know that which one is better to use jsp:useBean or import statement .
I can instantiate and call method of myclass -
1) by importing the class through import tag in jsp as <%@page import="myclass"%. or
2). by using <jsp:useBean tag....
i have these two option to do the same thing. i know that basically useBean is used to call setter and getter method of bean class and but it can be used to call a normal java file that have some logic .
so what should i used , which one is better and why?
useBean provides scope and object instance so no need to create object by new operator. and with import you have to create an instance .
but which tag should i use in my jsp?
i am confused???ok, means i can use jsp:useBean tag for all my
classes that are not actually bean. so it will be
instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
>
but when should i use import statement in my jsp and
it happen at translation time so will it create any
type of burden for my code if i import multiple
classes.For non-java beans, you need to import the classes, period.
It's not a burden, it's a necessity. -
Display binary data from DB in browser using JSP
Hello everyone:
I uploaded some files from browser and stored the files in bytes in the database, but later on I could not display the files in browser without saving them to a local storage first. Is there any way I can send the bytes to the browser in the right format using JSP?
I tried the following:
response.setContentType(..)
response.getOutputStream().write(bytes);
I can see that the browser can get the right contentType, but with a bunch of weird symbols in the browser. Please help.
Thank you very much for your time.
HeatherI actually had to do this a few months ago. There are ways to perform this kind display using various distributed object (i.e., using MS Word OLE objects to "interpret" the byte for you, etc.). But this soon got extremely difficult to manage (and I actually had to use Perl/CGI for the majority of it).
The solution I went with was to implement a "cache" directory on the web server. Basically, the JSP/Servlet can simply check the cache and if file not there, create it from the database. Then send a redirect back to the browser to this newly-created file. The browser will then appropriately open the document. I tested this with both Netscape and IE browsers and common MIME types such as text files, MS Office docs, zip files, PDFs, RTFs.
Not ideal, but unfortunately the best I came up with. -
Problem using jsp:include from inside a custom tag
Hi, All !
I have a problem using <jsp:include> from inside a custom tag. Exception is:
"java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
could not do this. Is it a bug, since in the 1.1 spec is said: "The
BodyContent is a subclass of JspWriter that can be used to process body
evaluations so they can retrieved later on."
My code is:
<wfmklist:items>
<jsp:include page="item.jsp" flush="true"/>
</wfmklist:items>
This is an area of contention with WL. It is not so tolerant with regards to
the spec. I spent several days recently trying to convince it to accept the
specification in regards to bodies and includes and it appears to have
successfully rebuffed my efforts.
Frankly, this is very disappointing. It appears that some shortcuts were
taken on the way to JSP 1.1 support, and the result is a very hard-coded,
inflexible implementation. As I have not seen the implementation myself, I
hate to assume this, however one could posit that the term "interface" was a
foreign concept during the implementation, other than as some annoying
intermediary reference requiring an immediate cast to a specific Weblogic
class, which in turn is apparently required to be final or have many final
methods, as if being optimized for a JDK 1.02 JIT.
I am sorry that I don't have any positive suggestions other than to use a
URL object to come back in an execute the necessary "include" directly. You
lose all context (other than session) and that can cause its own problems.
However, you can generally get the URL approach to work, and you will
hopefully avoid further frustration.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com
Tangosol: How Weblogic applications are customized
"Denis" <[email protected]> wrote in message
news:[email protected]...
> Hi, All !
> I have a problem using <jsp:include> from inside a custom tag. Exception
is:
> "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
>
> Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
> could not do this. Is it a bug, since in the 1.1 spec is said: "The
> BodyContent is a subclass of JspWriter that can be used to process body
> evaluations so they can retrieved later on."
>
> My code is:
> ...
> <wfmklist:items>
> <jsp:include page="item.jsp" flush="true"/>
> </wfmklist:items>
> ...
-
Problem using jsp:forward in java script
hi,
when I use jsp forward tag inside java script i'm getting a problem that
when the jsp is invoked it is getting forwarded to the page specified in the forward tag, without checking the if conditions. Following code may give you a better idea.
<html>
<script>
function test()
if(document.f.htemp.value=="true")
alert("jus");
else
var s=document.f.htemp.value;
alert(s);
<jsp:forward page="success.jsp" />
</script>
<body>
<form name="f" method=post>
<input type=text name=htemp value="true">
<input type=button onclick="test()">
</form>
</body>
</html>
please help me,thanks inadvance
regards
chanduWhat pgeuens means is that you can't mix javascript and jsp/java code in this way.
ALL of the jsp/java code gets executed at the server end.
This produces an HTML page (with embedded javascript) which gets sent to the client.
The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
<%
if (testCondition){
%>
<jsp:forward>
%<
%>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
<script>
function test()
if(document.f.htemp.value=="true")
alert("jus");
else
var s=document.f.htemp.value;
alert(s);
document.f1.action="success.jsp";
document.f.submit();
</script>You cannot run JSP code based on your javascript code.
Java. Javascript. Not the same thing.
Hope this helps,
evnafets -
File Transfer b/w Client - Server using JSP
Hi,
I need to implement a file transfer between the client and the server using JSP / Beans. The files can be XML Documents, Images (.gif,.jpeg) or even MS Word documents.
The user has a set directory on his file system where the files are to be saved upon download and retrieved upon upload. This system is similar to a check-in check-out system.
How do I get a reference to the directory on the users file system and then either save the downloaded files there or retrieve the files that need to be uploaded.
Thanks
coffeejavaThe only way you can do this is by using an applet, a jsp page or servlet does not have access to the system that the browser is running on. Furthermore if you were planning on using the html file form object you cannot set a value for that programmatically. It's not allowed for security reasons.
-
Writing Html Content into PDF using JSP
Dear All,
I am using JSP to generate Employee payslip dynamically. Presently i am diplaying payslip as on-screen display.
Here i want to give option "Save as PDF". I am able to create PDF file using IText Libraries. i want to integrate HTML code into the PDF file.
Writing HTML Content (using HTML Tags) into PDF.Well it is a difficult ask and i believe we are trying to re-invent the wheel
Just to make my life simple i could have choosen either sample API given below to serve my cause
1).[http://xmlgraphics.apache.org/fop/] (Apache FOP one can simply write an XSL template of their and then substitute the values from respective DTO's by using XSL - XML transformations and can generate content in different formats which includes PDF aswell)
2).[http://jasperforge.org/plugins/project/project_home.php?group_id=102] (Just design a simple report template using iReport and create a jrxml files and write a small code snipett such that you can pass few details at the runtime and can export the report in different formats which includes PDF aswell)
3).[http://www.object-refinery.com/jfreereport/] (Is much similar to what jasper offers in order to compile these you can either use pentaho product IDE or BEA/Oracle Actuate report tools)
You can simply try searching for different examples for getting more help on using the respective API's
Hope that helps :)
REGARDS,
RaHuL -
Using JSPs as a generic text template language
I am about to start a project with a lot of code generation. I intend to use templates to minimise the amount of println's in my code and to ease maintenance.
I am looking at this style of code:
For each file to be generated:
1) Set up a Javabean with the relevant data
2) Call a template which will substitute data from the Javabean
3) Output the stream from that template to a file
I have looked at Velocity which is easy to call from Java without requiring a URL request. However, I would like to use the JSP syntax as this provides a standard way for me to do my templating (I already use JSPs for web page generation).
Does anyone know how I can use JSP s in this way, i.e. calling them from a command line. I have tried using jspexcutor but have had severe diffiulties when using with Tomcat 3.3.
Thanks in advance
MartinI'm doing this now to generate Data Access Objects. I wrote the template as a JSP file, and I'm opening up an URL connection and writing the results to a Java source file. It works, but it's not pretty. I'm also looking for a nice way to do templating but haven't found anything so far. If you find something please let me know.
Mark
Maybe you are looking for
-
I Forgot my Apple ID password and I can't reset it because the related email account has been closed and the security questions don't work! How do I solve this? Thank you.
-
I don't know how to deactivate my iTunes card
i put my itunes code in at the wrong email
-
Hi, I am using HTTP adapter to send messages to third party. What happens if the handshake between XI and 3rd party fails? Will the messages be lost or will they queued? or do they they need to be re-processed?..So is there an automatic method in c
-
Hi, Present in this system user has facility to reverse the delivery (VL09) though there are sub sequent documents. (Ex; Proforma invoices, excise invoices), which have been not cancelled. Due to this my client excise department is getting many compl
-
Variables selection not appearing while executing query
hi, am using 3 variables in my query all 3 are ready for input, but still when am testing it in another username, the system does'nt give the selection options and the query is executed automatically. 1 of the variables use company as characteristic.