Including HTML text files in JSP where filename is variable
Hi
Myself new to JSP codings please do let me know via code how can thi s be done .
i have to call a HELP JSP for the page user is navigating
Help.jsp comes in popup. I have included header file in it HElp
_header.jsp
in help_body.jsp an HTML text file will be included but problem is this
file will be decided at runtime.
could you let me know how to pass variable file names in include .
for the moment i will use if else
After that help file location has to be fetched from session.
Hi
Myself new to JSP codings please do let me know via code how can thi s be done .
i have to call a HELP JSP for the page user is navigating
Help.jsp comes in popup. I have included header file in it HElp
_header.jsp
in help_body.jsp an HTML text file will be included but problem is this
file will be decided at runtime.
could you let me know how to pass variable file names in include .
for the moment i will use if else
After that help file location has to be fetched from session.
Similar Messages
-
Hi all,
I can call html or jsp file from jsp file, but how can I call text file in jsp, I put my text file same lever asmy jsp file it don't work!
where I should put the text file??
thank youmary,
since you knew the file name ,when clicked in name send to server,read the file and write to servlet outputstream.
I think this would help you.
If anything wrong in mycode ..forums will help you further
BufferedInputStream bis=null;
BufferedOutputStream bos=null;
int bytesRead=0;
byte buff[]=new byte[1024];
File f=new File(test.txt);
try{
bis= new BufferedInputStream(new FileInputStream(f));
bytesRead=bis.read(buff,0,buff.length);
if(bytesRead!=-1){
// create a BufferedOutputStream from ServletOutputStream
bos=new BufferedInputStream(response.getOutputStream());
do{
bos.write(buff,0,bytesRead);
}while((bytesRead=bis.read(buff,0,buff.length))!=-1)
}catch(Exception e){
////error handling
} -
Including a *.js file in JSP
Is this the correct way to do it?
<script LANGUAGE="JavaScript" SRC="./includes/calendar.js"></script>Hi
Follow Following Steps
1) Create scripts.js File, Add following content in this file
function popupaddpackage(urlToOpen) {
var window_width = screen.availWidth/5;
var window_height = screen.availHeight/5;
var window_left = (screen.availWidth/2)-(window_width/2);
var window_top = (screen.availHeight/2)-(window_height/2);
var winParms = "fullscreen=no"+",location=no"+",menubar=no"+",titlebar=no"+",toolbar=no"+",Status=no" + ",resizable=no" + ",height="+window_height+",width="+window_width + ",left="+window_left+",top="+window_top;
var newwindow = window.open(urlToOpen,'_blank',winParms);
newwindow.focus()
2) Create test.jsp file, Add following content in this file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Simple jsp page</title></head>
<body>Place your content here in test.jsp</body>
</html>
3) Create index.jsp file, Add following content in this file
<HTML>
<script LANGUAGE="JavaScript" SRC="scripts.js"></script>
<BODY>
<html:form action="/actions/showSample">
<TABLE ALIGN="CENTER" CELLPADDING=0 CELLSPACING=0>
<TR>
<TD><html:submit onclick="popupaddpackage('test.jsp')" value="Add Package" style="height:23;width:100"/></TD>
</TABLE>
</html:form>
</BODY></HTML>
Thanks
aMiT Pandya
[email protected] -
Reading text files in JSP pages
I want to know if it's possible to read a file and display it in an html:text area on a jsp page.
What I have right now is:
<html:file property="theFile" style="query-table-item" onclick="uploadFile(document.searchReportForm.theFile);"/> <html:reset title="Reset"/>what I wish to do, is to implement the uploadFile function, so that it can read from a text file and display it's contents onto the html:file area.
uploadFile is a javascript function that is being called from a javascript file.
I want to know if I can read the browsed file using javascript.
and if so, does someone have an idea how to do it?
Please help me out.Double post http://forum.java.sun.com/thread.jspa?threadID=647550&tstart=0
-
Download a text file from JSP (Urgent Please!)
Hi,
I have a issue with this JSP, I need to download a txt file from my webserver to the pc client, the page shows the dialg box but appear the filename (list.jsp) of my jsp instead of the txt file.
If I click the save buton save the list.jsp page; if I click in the open buton, then appear again the dialg box and now appear the url (download.jsp?filename=...) and if I click in the save button now I can save my txt file in the local pc.!!!!
Any ideas ??
list.jsp --> is the jsp from the download.jsp is run.
download.jsp
<%@ page import="java.io.*,javax.servlet.*,java.util.* "%><% String filename = request.getParameter("filename");
response.setContentType("application/download");
String value = "attachment; filename=\"" + filename + "\";" ;
response.setHeader("Content-Disposition",value);
int iRead;
FileInputStream stream = null;
try {
File f = new File("C://test//" + filename);
stream = new FileInputStream(f);
while ((iRead = stream.read()) != -1) {
out.write(iRead);
out.flush();
finally {
if (stream != null) {
stream.close();
%>Maybe try no quotes around the content disposition header?
Also, I'm not sure that application/download would be the best content type, maybe "application/octet-stream" instead. You should also probably explicitly set the Content-Length header to the file size. -
How to define special character in html text file used in loadvars
Hi
I'm witing some maths software and need to use the division
sign in a text file which is loaded using LoadVars().
The variable loaded is then assigned to a text area. Here's
the variable example.
&hint1=<title><b>Challenge 1: Instant recall
of any table</b></title><p>Including table
divisions eg 56 ÷ 8= </p>
the division sign is missing or a just a box. I've already
tried most options: ÷ (which works in XML loaded to
flash), ÷ %F7
Can anyone help please?Hi Michael. Thank you for your reply.
There is no declaration within sgm file itself - but while opening the file I use sgml application definition with the following settings:
Default API client: FmTranslator
SGML character encoding: ISO Latin1
XML character encoding: UTF-8
Namespace: Enable
CSS2 Preferences:
Generate CSS2: Disable
Add Fm CSS Attribute To XML: Disable
Retain Stylesheet Information: Disable
Entity locations
Entity search paths
C:\Program Files\Adobe\FrameMaker9\Structure\sgml\isoents
So as you can see, character encoding is set to ISO Latin1 (there is no way to use UTF-8 encoding in sgml files)
Typing ź or ć in sgm document and opening it with framemaker sgml application - I receive: ¿æ and message: "Non-SGML character found; should have been character reference"
Everything works fine when I type f.ex.: &x016B; and insert appropriate reference lines into isolat1.rw and isolat1.ent files
But what I would like to avoid is editing those isoent files each time new character is be needed. -
How to create a text file from jsp?
In JSP, what is the command to create a text file and dump a variable in it?
You mean StringBuffer?
-
Hi,
How do i include an external .js(JavaScript) file into a JSP file?My .js file is located in some package(lets say abc.jar). Below is my application structure:-
jsp
|
->MyJsp.jsp
lib
|
|
abc.jar
|
|
->com.abc.test
|
|
->Test.java
->abc.jsHow do i include "abc.js" file in "MyJsp.jsp" file?
Please help.
Thanks,
Kiran
Edited by: Adimulam on Jun 2, 2008 1:22 PMEven this is also not possible because, the code in that package is developed by DWR and i am just adding it to my lib folder and importing the respective classes. In the same manner i need to include the *.js* file in the JSP.It took me about 3 minutes reading through the [DWR Getting Started|http://getahead.org/dwr/getstarted] page to learn that you don't have to do any of that. Perhaps you should read that page?
-
Merging text files along with their filename
I am looking to merge a whole bunch of text files into one document. I am going to the Insert tab and selecting the drop down menu in Object to select text from file. All of the text is merging in the one document correctly, but I am not
getting the title/file name of the document inserted in the document and I would like that to be in there. Is there a way of doing this?Try the following macro. It assumes you're working with doc, docx & docm files. If not, change the 'doc' in the '*.doc' reference to whatever file type you're working with.
Option Explicit
Public oFolder As Object 'the folder object
Public i As Long, j As Long
Public DocTgt As Document
Sub Main()
' Minimise screen flickering
Application.ScreenUpdating = False
Dim StrFolder As String
' Browse for the starting folder
StrFolder = GetTopFolder
If StrFolder = "" Then Exit Sub
' Initialize the counters
i = 0: j = 0
Set DocTgt = ActiveDocument
' Search the top-level folder
Call GetFolder(StrFolder & "\")
' Return control of status bar to Word
Application.StatusBar = ""
' Restore screen updating
Application.ScreenUpdating = True
MsgBox i & " of " & j & " files processed.", vbOKOnly
End Sub
Function GetTopFolder() As String
GetTopFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetTopFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
Sub GetFolder(StrFolder As String)
Dim strFile As String
strFile = Dir(StrFolder & "*.doc")
' Process the files in the folder
While strFile <> ""
' Update the status bar is just to let us know where we are
Application.StatusBar = StrFolder & strFile
Call UpdateFile(StrFolder & strFile)
strFile = Dir()
Wend
End Sub
Sub UpdateFile(strDoc As String)
Dim Doc As Document
' Open the document
Set Doc = Documents.Open(strDoc, AddToRecentFiles:=False, ReadOnly:=False, Format:=wdOpenFormatAuto, Visible:=False)
With Doc
If .ProtectionType = wdNoProtection Then
With .Range.Sections
With .First.Footers(wdHeaderFooterPrimary).Range
.InsertBefore Doc.Name & vbCr
While .Characters.Last.Previous = vbCr
.Characters.Last.Previous = vbNullString
Wend
End With
.Add Start:=wdSectionBreakNextPage
End With
DocTgt.Characters.Last.FormattedText = .Range.FormattedText
' Update the file counter for processed files
i = i + 1
End If
' Update the main file counter
j = j + 1
.Close SaveChanges:=False
End With
' Let Word do its housekeeping
DoEvents
Set Doc = Nothing
End Sub
With this code, each merged file's name will be added to its footer.
Cheers
Paul Edstein
[MS MVP - Word] -
How to send a text file as jsp response
Hi
I want to send a text file/or other file as jsp response ..How to do it..
Pls tell me if any body knows about it..
thanksHmmm im no expert but i think you would have to convert it to a byte array and use OutputStream with the response ... not sure ...like i said, im no expert
-
What is the best way to include an xml file in JSP?
I have a jsp page that I need to include an xml file. The xml file
uses an xsl to render the file. What is the best way to include the
xml file and still maintain the structure of the style sheet?
Thanks
Jennifer
The best way is using the tag lib. If you cannot, but you can use JAXP, you can
try
javax.xml.transform.Transformer.transform(Source xmlSource,
Result outputTarget)
throws TransformerException
You construct the transformer with you xsl, use you xml file or DOM to form xmlSource,
and use JSPWriter "out" to form outputTarget (StreamResult). But if your JSP page
generates the xml itself, tag lib is the only way.
[email protected] (Jennifer) wrote:
>[email protected] (Jennifer) wrote in message news:<[email protected]>...
>> I have a jsp page that I need to include an xml file. The xml file
>> uses an xsl to render the file. What is the best way to include the
>> xml file and still maintain the structure of the style sheet?
>>
>> Thanks
>>
>> Jennifer
>
>Or is there a way to parse the xml file with the jsp page to display
>the information. I cannot use the Java Standard Tag Libraries as the
>version of iplanet we are running does not support the JSTL
>
>Thanks
>
>Jennifer
-
When I send text files, TB inserts them into the body, as well as attaching the files separately. I don't want them in the body, and I can't find a way not to do that. I've looked all through the options, but the only thing that's close refers to forwarding messages, and changing that did no good. Thank you.
OK, that explains a little. On my Web-based mail system, the files are attached, not embedded. When I sync that account (IMAP) with TB on my desktop, they're both embedded and attached. Time to look at the options on my desktop.
On the sending PC, TB shows the sent message with the text as both embedded and attached.
I've used TB for several years on my desktop, and have never noticed this behavior. I just had to replace the other PC, and changed from Eudora to TB. Maybe all of the options aren't set right, so I'll compare them to my desktop's settings.
I'm open to more suggestions if you have them. -
Style Image Slider to include HTML text: How?
I am trying to insert an image slider onto my page. So far, I have tried a few different sliders with some issues.
Does anyone know
A good Jquery Image Slider that allows for HTML text beside the image on a slide?? (Like MSN Homepage)--No Caption or Overlay. Looking for White background with linkable HTML Text on left (40%) and Picture on Right (60%)-all on one slide. Cycle through four similar slides.
I am assuming the solution is not so much the slider, but has to do with creating a seperate div or rule / class and applying?
Thank you for any help.I would approach it like this:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 document with Cycle2</title>
<!--Latest jQuery Core Library-->
<script src="http://code.jquery.com/jquery-latest.min.js">
</script>
<!--Cycle2 Plugin Script-->
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20130409/jquery.cycle2.min.js"></script>
<style>
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
.cycle-slideshow {
margin: 25px auto;
border: 1px solid silver;
overflow: hidden; /**float containment**/
width: 80%; /**adjust width of container as required**/
.cycle-slideshow img {
width: 60%;
float: left;
.cycle-slideshow h3 {
float: right;
width: 40%;
font-size: 26px;
color: red
.cycle-slideshow p {
clear: right;
float: right;
width: 40%;
font-size: 16px;
.center {text-align:center}
/* Special Rules for tablets, mobiles */
@media only screen and (max-width: 768px) {
.cycle-slideshow { width: 98% }
.cycle-slideshow img {
width: 100%;
display: block;
float: none;
.cycle-slideshow h3 {
display: block;
float: none;
font-size: 20px;
width: 100%;
.cycle-slideshow p {
display: block;
float: none;
font-size: 14px;
width: 100%;
</style>
</head>
<body>
<h1><a href="http://www.malsup.com/jquery/cycle2/">jQuery Cycle 2</a>
Responsive Slideshow with text</h1>
<!--begin slideshow-->
<div class="cycle-slideshow"
data-cycle-pause-on-hover="true"
data-cycle-timeout="2000"
data-cycle-next="#next"
data-cycle-prev="#prev"
data-cycle-slides="> div"
>
<div>
<img alt="description" src="http://placehold.it/400x100">
<h3>Slide 1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris vitae libero lacus, vel hendrerit nisi! Maecenas quis velit nisl, volutpat viverra felis. </p>
</div>
<div>
<img alt="description" src="http://placehold.it/400x100">
<h3>Slide 2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris vitae libero lacus, vel hendrerit nisi! Maecenas quis velit nisl, volutpat viverra felis. </p>
</div>
<div>
<img alt="description" src="http://placehold.it/400x100">
<h3>Slide 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris vitae libero lacus, vel hendrerit nisi! Maecenas quis velit nisl, volutpat viverra felis. </p>
</div>
<div>
<img alt="description" src="http://placehold.it/400x100">
<h3>Slide 4</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris vitae libero lacus, vel hendrerit nisi! Maecenas quis velit nisl, volutpat viverra felis. </p>
</div>
<div>
<img alt="description" src="http://placehold.it/400x100">
<h3>Slide 5</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris vitae libero lacus, vel hendrerit nisi! Maecenas quis velit nisl, volutpat viverra felis. </p>
</div>
<!--end slideshow-->
</div>
<!--prev, next links-->
<div class="center">
<a href=# id="prev">Prev</a> | <a href=# id="next">Next</a>
</div>
</body>
</html>
Nancy O. -
How to load a text file (ASCII) into a TS string variable?
I need to load a ASCII file into a TS string variable for subsequent processing. I tried the SecuenceBuilder DLL (in the examples directory) but it seems that this DLL has a bug. Some text files are not loaded properly. I have also tried the kernel32 functions (openfile, createfile, readfile ... ) handling them as a C program, but with no success. The property loader feature of TS is not the suitable solution for me, because I would have to modify all my text files to include some specific fields (step name, variables, starmarker ...). Doy you know an alternative procedure to load text files or any DLL that implements what I look for ? Any help would be grateful. Cesar ([email protected])
Hi Cesar,
I don't know if you have found a solution, but attached is a DLL built in VC that will read the text out of a file into a TestStand variable. The attached sequence file \SequenceFile1.seq contains a step type that is set to call the DLL responsible for reading the file. It reads the file specified under Step.FilePath and stores the data in Step.ReadData. Please let me know if this works for you. I have attached the source as well.
Regards,
Bob
Attachments:
ReadFile.zip 3628 KB -
How to download a text file using jsp i
I want to provide download facility in jsp page.
if i have exe download is working . If I have a text / html file it is just displaying I want to make it download How to do it?
regards
subrahmanaymaIf you want to get an "Save as" dialogue, then you need to set the content-disposition in the header to "attachment". The default value is "inline".
Best solution is to create kind of a FileServlet and let it stream the right file as a download to the client. You may find the downloadFile() snippets at the bottom of this article useful: http://balusc.xs4all.nl/srv/dev-jep-pdf.html Put it in a FileServlet and call it using for example .
Maybe you are looking for
-
After upgrading my ATT iPhone 4 to iOS5, I thought I would try out iCloud. I read somewhere, that it only syncs when it is connected to a powersource, and maybe I read that wrong, but I interpret it to mean when I am connected to either a power outle
-
Got my iPhone4... and a question...
So first let me say wow... this is my first iPhone and I must say I am quite impressed with the OS itself. Very smooth and peppy. Kudos to the folks at Apple! Kudos also due to the fine folks at the Apple Store here in Albuquerque, NM. I signed up to
-
Why does a new tab (middle click) in a new window open in the original window?
In FF 4 Beta 11 I open a new window, middle click a link in the new window, but the new tab opens on the original window. Why doesn't it open in the new window? Are there settings to alter this behaviour?
-
Skype home unavailable and not letting me make cal...
I have windows 8 on my desktop. I just downladed Skype so it is the newest version. I can sign in however the home page is unavailable, I can't add contacts, or make calls. I have disabled any automatic updates still not working.
-
Authorization log / Hierarchy node in SQL format
Hi! I execute rsudo on a restricted user and the authorization log tells me that this fails because the user is not authorized for "Content(in SQL format): Node 5 8 0 31 E" Now how do I translate this sql format into something I can read? I've looked