How to include something in servlet
if i have a header file for open html and i have a footer file for close html
how i can i use it in a servlet just like in php require("header.php");
By using RequestDispatcher Object u can deo it,d code shown below will help to solve ur problem
RequestDispatcher rd=getServletContext.getRequestDispatcher("/urlOf theHtmlFile");
rd.include(HttpServletRequest req,HttpServletResponse resp)
Similar Messages
-
How to include log4j in servlet
hai
i want to know what are the steps neccessary for including log4j .How to do with xml.
Please give me some useful sites about log4j. which will guide me to work in webapplicationhttp://www.google.com/search?hl=en&lr=&q=log4j+help
:) -
How to include other web page in servlet response?
Is there any way how to include the contents from some other web page in my own response? For example, I wish to printout some text and below that to put the complete contents of let's say Google's page, so something like:
include("www.google.com");
...So far I found that I can either redirect to that page and l fully lose the control or include the contents of the other jsp or servlet that I made in the same project. I know I can just send the request to that outside page and read the response and print it out on my page, but the problem is when there is a JavaScript and I can't get the rendered contents but just that script. Also, I will not be able to see the images in that case, so I prefer to give the command to web browser to render and show it for me.
Thanks a lot for any help!I already tried with streams but then just original source is written, so it means that if it is calling some scripts I will get JavaScript code instead of executed result. I thought I must somehow make the browser to process the page and just display the output because it knows how to deal with scripts.
-
How to "include" another page or servlet in a standard servlet
How can I achieve a "include" in a servlet?
From what I see... the include() method is on the PageContext class, which is in org.apache.somewhere... right??
Or am I missing something?
thanksHow can I achieve a "include" in a servlet?
From what I see... the include() method is on the
PageContext class, which is in org.apache.somewhere...
right??
Or am I missing something?
thankshttp://java.sun.com/webservices/docs/1.0/api/javax/servlet/RequestDispatcher.html#include(javax.servlet.ServletRequest,%20javax.servlet.ServletResponse) -
How to include images into a servlet
Hi guys,
I found out that I can't include both the "setContentType("image/gif")" and the "setContentType("text/html")" in a servlet. I've tried different methods, but I can't get it right.
Could anyone tell how to do that...?
Thanks...I beg your pardon? You want to send text and image in the same response? Can't be done. If you go and look at pretty much any HTML page on the web you will see how to include images in HTML.
-
How do i run a servlet??????
running servlets:i downloaded jsdk but how do i run a servlet? i got the error
C:\WINDOWS\Desktop>javac HTTPGetServlet.java
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
ain
when i tried to run my servlet, please help
thanksAs mentioned in another post in the thread, servlets run from within a web server that has pre-loaded the jvm and serves web requests. Often they are called 'sevlet containers' as they act like a wrapper program for the actual vm. Tomcat is such a web server, quite a popular one for running servlets, and is considered the reference implementation for a sevlet/jsp server. you can read up on it at...
http://jakarta.apache.org/tomcat/index.html
To get you started, this is what i did to set up tomcat. Im using RedHat Linux at home, so this may differ to what you have to do initially.
First, make sure you have at least the jsdk and jsdk ee installed and the appropiate JAVA_HOME and J2EE_HOME environment variables set.
I am using the Apache web server to handle web page requests on my box. If the request is for a context containing a servlet or jsp file (context is a tomcat term for a particular location or path in the url) then apache passes the request to tomcat via a apache module and a special protocol. Tomcat then runs the .class file or .jsp file, returns the output to apache which then returns the output back to the browser. So initially you should set up and have the apache web server running.
Next download and install the jserv or tomcat module for apache, which apache uses to communicate with tomcat via a special protocol, and the tomcat rpms from...
http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/rpms/
...Im using 3.2.3 which works fine. you may try the later versions if you like.
Install the tomcat rpms. They should dump a whole lot of stuff in a /var/tomcat directry, including some nice sample and admin apps. if you had downloaded and installed the tomcat-manuals rpm you can find lots of helpful information in the /usr/doc/tomcat-{your version here}/ directry. This is what you should probably read through now!
Once that is done, its simply a matter of adding a reference in your httpd.conf file to the tomcat.conf file in the tomcat/conf dir (if you want to have complete control over the tomcat module and contexts) or tomcat-apache.conf (in the same directry) if youd like tomcat to handel its own configuration of apache. something like...
include /var/tomcat/conf/tomcat.conf
...should do.
then run tomcat start (in /usr/bin/) and apache and away you go. You should be able to point your browser to your.server.com/admin/ and get the tomcat admin tools. This allows you to add view and delete contexts to your server (say for separating different server-side applications). your.server.com/examples/ has some nice stuff as well.
Hope this helps. I warn you im not an expert and haven't looked at this stuff for some time. I probably have something wrong so please, experts, if you see something stuffed up let us know. -
How to include a jsp page in another jsp jsp page
hi,
i m trying to include a jsp page name "header.jsp" into one jsp page name"selectattribute.jsp" i m using these commands in "selectattribute.jsp"
<%@include file "header.jsp"%> bcz both these jsp page are C:\program files\tomcat 4.0\webapps\examples\jsp\Poject\
but the problem is that , i m invoking this jsp page "selectattribute.jsp" from a servlet reportcontroller.java using REQUEST DISPATCHER.
the servlet is in
C:\Program files\tomcat 4.0\webapps\examples\WEB-INF\classes\Project\
i want to know how to include some other jsp page in a jsp page and how to invoke applet from jsp page when that particular jsp page is being invoked by servlet.
plz help
manishuse this for including in your selectattribute.jsp
<jsp:include page="header.jsp" flush="true"/>
I never tried calling an applet. I think you can write the code for calling the applet in a javabean method and call the method in the jsp -
I would like to know how to include entries in my TOC that refer to paragraph styles listed before the TOC.
Example:
page i. Title Page
page ii. Abstract
page iii. Table of Contents
I want the TOC on page iii to include the entries "title page" and "abstract". Is this possible?
Thank you-Thesis formatting rules.
Can you answer another question?
How do I change the text for a TOC entry? For example,
I have selected the title on my first page, for example "Summer Report" and selected a paragraph style for it, and added it in the TOC. Now the TOC will have this entry for "Summer Report" and the associated page. But I want it to say "Title Page" instead. Can I edit this text? In order words, have the TOC point to something with whatever name I want to give it, even though it is not the actual name of the section? -
Hi, I was told in another of the forums that my issue
is best suited for the TechNet audience. Previously, I posted it here: http://answers.microsoft.com/en-us/windows/forum/windows8_1-system/how-to-include-a-kb-update-into-a-wim-in-order-to/e7015076-b4a9-4862-a73b-6c58b4c82461?tm=1409598696763
I've been struggling to fix a corrupted file.
Context: I feel that something is not right with the computer, so I started poking around.
I used "sfc /scannow" from an elevated command prompt and the result was:
Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.Log <var style="border:0px;margin:0px;padding:0px;vertical-align:top;-webkit-font-smoothing:antialiased;">%WinDir%</var>\Logs\CBS\CBS.log.
I looked in the log. This message appears 4 times:
Cannot repair member file [l:36{18}]"Amd64\CNBJ2530.DPB" of prncacla.inf, Version = 6.3.9600.16384, pA = PROCESSOR_ARCHITECTURE_AMD64 (9), Culture neutral, VersionScope = 1 nonSxS, PublicKeyToken = {l:8 b:31bf3856ad364e35}, Type = [l:24{12}]"driverUpdate",
TypeName neutral, PublicKey neutral in the store, hash mismatch
There is also the following message:
This component was referenced by [l:186{93}]"Microsoft-Windows-Printer-Drivers-Package~31bf3856ad364e35~amd64~~6.3.9600.16384.INF_prncacla"
I'm not positive what to do next, but I have been led to believe the problem is that Flash files in version 6.3.9600.16407 are corrupted, that I need to find which KB updates Flash to this version, download the file, add it to a new WIM, and point
to it when using DISM. I'm not positive this is correct, but it was suggested.
I downloaded the KB update: kb2889543, but I do not know how to add it to a new WIM or what the repercussions of doing so will be (e.g. Will I lose everything and have to restore my documents, etc from my external drive by doing this?).
So, the question is: How can I include a KB Update into a WIM and tell me what the result will be when once I do and point to it when using DISM?
Secondarily, if this is a bad way to move forward with the issue, would some kind soul offer sage advise on how to move forward with resolving the original issue?Hi TTQSTTQS,
As you mentioned in the answers forum, when run the command DISM /Online /Cleanup-Image /RestoreHealth, we received the error message “The source files could not be downloaded. Use the "source" option to specify the
location of the files that are required to restore the feature”.
When run the command Dism /Online /Cleanup-Image /RestoreHealth /Source:c:\test\mount\windows /LimitAccess, we met the same error message.
I think there are some mistakes in the source setting, so we meet the same error messages.
As I mentioned in the last reply, we need a mounted image as a repair source, and then use this path.
We need to configure a Windows repair source. Please refer to the following article.
http://technet.microsoft.com/en-us/library/hh825020.aspx
Please refer to the following steps to set the source image.
1. Assign Drive Letters to Partitions by Windows PE.
2. Capture Partition Images using DISM
For more information, please refer to the following article.
http://technet.microsoft.com/en-us/library/hh825072.aspx
Then, we could try the command Dism /Online /Cleanup-Image /RestoreHealth /Source:c:\test\mount\windows /LimitAccess.
Best regards,
Fangzhou CHEN
Fangzhou CHEN
TechNet Community Support -
Q: how to include a page in a region
Hi all,
i need some help
how to include the URL of a page in a region, my requirement is that i have some links in the page and i need when i press a link a region under it will be rendered below it not in another page
the links is ready and the pages is ready
just i want a the region to contain a url based on the selected link.
i know how to make a region rendered or not.
and i have tried to use URiInclude but i couldn't figure out exactly how to do it
i have also searched the forum and i couldn't find something about it.
so please if any one knows the solution or can provide me with a link, i will be very thankful
thanksuser604057,
Technically you can't add a page to another page. A page can have only one pagelayout region. So you will have to make a copy of those pages as regions without a pagelayout region and use.
--Shiv -
How to include md5 package in application
Hi All,
First of all sorry I posted in another users thread. In the thread http://forums.sun.com/thread.jspa?threadID=5426671 the person used org.bouncycastle.crypto.digests.MD5Digest for doing md5.
I need some help here on how you include the org.bouncycastle.crypto.digests.MD5Digest library in my java code as I want to use the md5.
I am also working on something similar like that but without the web application part and a detail which consists on OTP part using md5.
As the md5() doesn't work in j2me so was also searching for something which will work on MIDP.
package com.abc; //package define
public class messDig5 //class define
private String generateHash(String OTP, int loopNum) {
byte[] secretBytes = OTP.getBytes();
for (int x = 0; x < loopNum; x++) {
byte[] tempStore = new byte[16];
tempStore = hash(secretBytes);
secretBytes = tempStore;
// return convertToHex(secretBytes);
return byteArrayToHexString(secretBytes);
public byte[] hash(byte[] secretBytes) {
org.bouncycastle.crypto.digests.MD5Digest digest = new org.bouncycastle.crypto.digests.MD5Digest();
digest.reset();
// Update MD5 digest with user secret in byte format
digest.update(secretBytes, 0, secretBytes.length);
// get length of digest to initialise new md5 byte array
int length = digest.getDigestSize();
// create md5 byte array using length
byte[] md5 = new byte[length];
// calculate MD5 hash, using md5 byte array, 0 for buffer offset
digest.doFinal(md5, 0);
return md5;
// private static String convertToHex(byte[] data) {
// StringBuffer buf = new StringBuffer();
// String Hex;
// String formattedHex;
// for (int i = 0; i < data.length; i++) {
// int halfbyte = (data[i] >>> 4) & 0x0F;
// int two_halfs = 0;
// do {
// if ((0 <= halfbyte) && (halfbyte <= 9)) {
// buf.append((char) ('0' + halfbyte));
// } else {
// buf.append((char) ('a' + (halfbyte - 10)));
// halfbyte = data[i] & 0x0F;
// } while (two_halfs++ < 1);
// Hex = buf.toString();
// formattedHex = "\n" + Hex.substring(0, 4) + " " + Hex.substring(4, 8) + " " + Hex.substring(8, 12) + " " + Hex.substring(12, 16) + " " + Hex.substring(16, 20) + " " + Hex.substring(20, 24) + " " + Hex.substring(24, 28) + " " + Hex.substring(28, 32);
// return formattedHex;
static String byteArrayToHexString(byte byteValues[]) {
byte singleChar = 0;
if (byteValues == null || byteValues.length <= 0) {
return null;
String entries[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"a", "b", "c", "d", "e", "f"};
StringBuffer out = new StringBuffer(byteValues.length * 2);
for (int i = 0; i < byteValues.length; i++) {
singleChar = (byte) (byteValues[i] & 0xF0);
singleChar = (byte) (singleChar >>> 4);
// shift the bits down
singleChar = (byte) (singleChar & 0x0F);
out.append(entries[(int) singleChar]);
singleChar = (byte) (byteValues[i] & 0x0F);
out.append(entries[(int) singleChar]);
String rslt = new String(out);
return rslt;Camellia,
I take you already added bouncycatsle to your project as a compile dependency, since it compiles (unless it does not).
All you have to do for your code to work on the phone, you need to build your JAR file (that you use to distribute your MIDlet) with bouncycastle packaged in. This will all depend on the method you use to build your JAD and JAR files.
I use antenna tool, which provides me with ant tasks to compile, build jar, package external libraries etc. Your scenario can be different, but all you have to do is to search manuals and/or google for methods on how to package external libraries with your build.
Daniel -
How to return URL of servlet path ?
Hello,
I want to return the URL of current servlet path (such as "http://www.mydomain.com:888/servlet"). How can I do that ?
thanks in advance...Hi danisment,
Checkout the API for javax.servlet.http.HttpServletRequest Interface in which you have the methods to get path information.
Use
request.getServletPath();Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string.
If you want the entire URL,
use request.getRequestURL(); returns the StringBuffer
The returned URL contains a protocol, server name, port number, and server path, but it does not include query string parameters
Hope this will throw some light for you problem.
Thanks,
Sanath Kumar -
How to include external files in JSP
hi,
How to include external files like image or javascript in to jsp pages.
I am using MVC frame work. So i have to use request dispatcher. While calling the pages trough dispatcher the external files are missing from the output. Also am using tomcat as server,web.xml(deployment descriptor ) is also configured.
regards
sreeWhen you use the request dispatcher, the relative path for all your ressources becomes the relative path of your calling serlvet and not the JSP/servlet that you call. Make sure to use the full relative path such as:
/PATH_TO_YOUR_DIRECTORY/myRessource.ext
NOT
SOME_DIRECTORY/myRessource.ext
Jeff -
How to include .jars?
Hello,
I have been unable to find out how to include in the .ear file generated by wsgen the supporting .jar files that my Web Service EJB needs.
I thought this could be done with the "classpath" parameter in the wsgen tag in build.xml, but it doesn't seem to do anything.
Can someone please provide a hint?
Thanks,
PereHi Pete,
You mentioned the <wsgen> Ant task, so I'm assuming that you're using WLS 6.1
An automated way to do this, is to include a series of <exec> Ant tasks after
the <wsgen> one. These <exec> Ant tasks would call the jar.exe and look something
like this:
<exec
dir="."
executable="jar.exe"
failonerror="yes"
>
<arg line="xvf ${APPLICATIONS}/MyWS.ear myEJB.jar"/>
</exec>
<delete dir="myEJB-jar"/>
<mkdir dir="myEJB-jar"/>
<exec
dir="myEJB-jar"
executable="jar.exe"
failonerror="yes"
>
<arg line="xvf myEJB.jar"/>
</exec>
<copy todir="myEJB-jar">
<fileset dir=".">
<include name="jar1-used-by-EJB.jar"/>
<include name="jar2-used-by-EJB.jar"/>
</fileset>
</copy>
<copy todir="myEJB-jar/META-INF">
<fileset dir=".">
<include name="MANIFEST.MF"/>
</fileset>
</copy>
<jar jarfile="myEJB.jar" basedir="myEJB-jar" />
<exec
dir="."
executable="jar.exe"
failonerror="yes"
>
<arg line="uvf ${APPLICATIONS}/MyWS.ear myEJB.jar"/>
</exec>
I realize this seems like a lot of steps, but they are at least automated :-)
Note that the contents of the MANIFEST.MF that you copy in must look like this:
Manifest-Version: 1.0
Created-By: Ant 1.4
Class-path: jar1-used-by-EJB.jar jar2-used-by-EJB.jar
in order for the EJBs to find the newly included .jar files.
HTH,
Mike Wooten
Pere Torrodellas <[email protected]> wrote:
Hello,
I have been unable to find out how to include in the .ear file generated
by wsgen the supporting .jar files that my Web Service EJB needs.
I thought this could be done with the "classpath" parameter in the wsgen
tag in build.xml, but it doesn't seem to do anything.
Can someone please provide a hint?
Thanks,
Pere -
How to include movie poster frames in iphoto contact sheet?
I cant see how to include movies in contact sheet. Is it possible? I'm using iphoto v8.0.2.
I suppose Old Toad's solution will work. However, this will change the dates on the originals and I don't think that is desireable in general.
I think there is a bug in the printing of contact sheets. If one selects all photos in an album that has been re-orded manually and then starts the print sequence, the initial sheet with 3 columns is ordered correctly. But, as soon as you try to change the number of columns the ordered reverts to date order of the originals.
Am I missing something or is this really a bug? If it is, how do I report it?
Maybe you are looking for
-
Check box rendering problem in List.
Hi All, I am using list component in my app and list component allows multiple selections. I am using an itemrenderer having the checkbox and label in hbox. Rendering is working fine. but when I selected three or four items randomly using
-
How can I find out who is mining my software for information about me??
Companies are taking my personal information and using it for pop-ups and other advertizements. How do I find out who is phishing for my information and how do I stop that?
-
Messages not displaying contacts in contact list
Hi all, I've just upgraded to OS X 10.8 and Messages doesn't display my contact list from the Jabber server I'm using. The contact list shows all groups, but no members. I've installed Adium to double check and it works fine. iChat never had problems
-
Where would be the best place to achieve this? I have been thinking about these options: - Modification of the Operator Interface. - Modification of the Sequence Model. - Use callbacks to modify the sequence model. - Use callbacks to modify the Engin
-
The detail algorithm of OLTP table compress and basic table compress?
I'm doing a research on the detail algorithm of OLTP table compress and basic table compress, anyone who knows, please tell me. 3Q, and also the difference between them