Jquery Uncaught SyntaxError - java

I've got a JSP which is outputting the following HTML:
<html>
<head>
<script type="text/javascript" src="jquery-1.4.3.min.js"></script>
</head>
<body>
</body>
</html>
When I open this page in Chrome, I get:
Uncaught SyntaxError: Unexpected token : jquery-1.4.3.min.js 120
jquery-1.4.3.min.js:-1Resource interpreted as script but transferred with MIME type application/octet-stream. jquery-1.4.3.min.js -1
When I open is in IE 8, I get:
Message: Expected '}'
Line: 109
Char: 466
Code: 0
URI: http://localhost:8080/jquery-1.4.3.min.js
I've had similar errors with JQuery 1.4.2 and with the unminified versions of the jQuery JavaScript.
Please could someone show me what I'm doing wrong?
Thanks.
UPDATE
I've fixed my mime-types, but I still get an error. Now it is simply a
Uncaught SyntaxError: Unexpected token :
Here are the response headers from the jQuery request on my server:
Cache-Control:max-age=32400, s-maxage=0
Connection:Keep-Alive
Content-Length:75134
Content-Type:text/javascript; charset=UTF-8
Date:Fri, 12 Nov 2010 11:28:21 GMT
Expires:Sat, 13 Nov 2010 11:28:21 GMT
Keep-Alive:timeout=15, max=100
Last-Modified:Fri, 12 Nov 2010 11:16:53 GMT
Pragma:cache
Server:Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)
Transfer-Encoding:chunked
The response headers from Google's file are:
Age:119
Cache-Control:public, max-age=31536000
Content-Encoding:gzip
Content-Length:26769
Content-Type:text/javascript; charset=UTF-8
Date:Fri, 12 Nov 2010 11:26:22 GMT
Expires:Sat, 12 Nov 2011 11:26:22 GMT
Last-Modified:Fri, 15 Oct 2010 18:25:24 GMT
Server:sffe
Vary:Accept-Encoding
X-Content-Type-Options:nosniff
The content types now look the same to me.
Any other ideas please?
SOLVED
The problem was nothing at all to do with jquery, mime types, etc.
It was our ant build file. There was a target in there (which we've had on this code for over 6 years) which tried to minimise any JS file using a regular expression search/replace. This was breaking the actual jQuery javascript file. D'oh!

It looks likely that your server is misconfigured, and is sending .js files as application/octet-stream instead of as text/javascript. I'm not sure why this would cause parsing errors like the ones you seem to be getting, though.
If you use the Google CDN URL for jQuery (http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js) do you get the same error?

You have something outside the question happening, some other includes interfering. These don't match up:
<script type="text/javascript" src="jquery-1.4.3.min.js"></script>
Note it's 1.4.3, while your error is 1.4.2:
URI: http://localhost:8080/jquery-1.4.2.min.js
Check for another file before your jQuery include that doesn't have a proper closing brace.

Related

Mime source string to object

I have a standard whole Mime source text string I need converted to either a Java or PHP object (or both if you want to show off !) so it can be manipulated in these platforms.
I have looked everywhere but only seem to be able to create from scratch.
So the below for example becomes an object that I can change headers or body parts, and the resend using the provided classes.
The require application for this is a distributed one, where I can supply customers a small java program while their local email app can point SMTP to, which I have done, and obtained Mime string as below.
I then want to be able to access and manipulate the various parts like headers and individual body parts before sending.
Surely there is some class or library which will offer this ? If necessary I can simply send the string to a PHP script if there is a suitable solution in PHP however its on a shared server so I cannot simply add PHP extensions.
Return-path: <tim#domain_a.com>
Envelope-to: XXXXXXXXXXXX
Delivery-date: Thu, 19 Sep 2013 09:54:17 +0100
Received: from XXXXXXXXXX [61.125]:62344 helo=[192.168.1.10])
by leopard.host-ns.co.uk with esmtpsa (TLSv1:DHE-RSA-CAMELLIA256-SHA:256)
(Exim 4.80.1)
(envelope-from <tXgham#dXm>)
id 1VMa09-000MOc-4T
for tiXham#daXcs.com; Thu, 19 Sep 2013 09:54:17 +0100
Message-ID: <523ABBB6.1080105#datXics.com>
Date: Thu, 19 Sep 2013 09:54:14 +0100
From: Txgham <tiXam#datXics.com>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
MIME-Version: 1.0
To: TiXham <tiXam#daXics.com>
Subject: Re: Example
References: <523ABB49.50403#daXnics.com>
In-Reply-To: <523ABB49.50403#daXhanics.com>
Content-Type: multipart/alternative;
boundary="------------000900010104080404030103"
This is a multi-part message in MIME format.
--------------000900010104080404030103
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Example showing reply subpart and HTML <apage.html>
On 19/09/2013 09:52, TiXgham wrote:
> Example email
--------------000900010104080404030103
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Example showing reply subpart and HTML <br>
<br>
<div class="moz-cite-prefix">On 19/09/2013 09:52, TiXam wrote:<br>
</div>
<blockquote cite="mid:523ABB49.50403#daXanics.com" type="cite">Example
email
<br>
</blockquote>
<br>
</body>
</html>
--------------000900010104080404030103--
This is out of date now and never did fully solve it. The issue was deemed as platform specific (iPhone) and not relevant after so much time.

Getting data from multiple-encoded file

I'm writing parser for Thunderbird mails.
Input:
I've got a file with load of emails (main part written in ANSI - WINDOWS 1250, but the content is in utf-8 or iso-8859-2, it is written in mail's Content-Type markup).
Output:
Collection of messages content (body).
So that's what I do:
Read whole file into a byte[] variable. (still ANSI)
Convert it to String. (utf-16 but bytes as from ANSI) - I need to convert to String now, because i need to get to the next point (divide bunch of messages -> sole message)
Divide bunch of messages into a separate message and add every message into Collection (utf-16).
Check Content-Type of a message.
Using JavaMail API i use mail.getContent(utf-16 I guess, but I'm not sure of encoding inside).
This is my problem: I have a String in UTF-16 i guess, and it's content is e.g. iso-8859-2, so what should I do now?
I was using Charset, and new String(byte[],String (charset name) ), but none of my tries made it.
My try:
Convert final String from UTF-16 -> UTF-8 (cause it's the same amount of bytes as in 8859-2)
Get bytes from utf-8 and encode it as ANSI
Decode ANSI to utf-8
Encode utf-8 to ISO-8859-2 (or leave it, if it already has been utf-8)
Decode from ISO-8859-2.
But it's not giving me any good results.
how may I deal with it? Too many decodings for me, and I feel dizzy.
Input (this was hold as a cp1250 file, but i converted it to utf-8, ):
From - Thu Dec 08 15:06:14 2011
(some mail header stuff....)
Content-Type: text/html; charset="iso-8859-2"
<table border="0" cellspacing="0" width="600"><tbody><tr><th class="ffield2"><span class="cald-word">clichéd</span> </th><td class="field1"><br>
banal; <b>banalny<b>
<br>
She made a <span class="cald-word">clichéd remark about the importance of friendship.</span>
<br>
<b>Wygԯsiԡ jakѶ banalnѠuwagꡯ wadze przyjaݮi . <br>
<b>
<b> <b><br>
</td></tr></tbody></table>
From - Thu Dec 08 15:42:09 2011
Content-Type: text/html; charset=utf-8
(some mail header stuff....)
<table border="0" cellspacing="0" width="600"><tbody><tr><th class="ffield2">nosiness</th><td class="field1"><br>
<br>
interest in somebody else's business; <b>wścibstwo<b>
<br>
Nosiness is something I can't stand, so stop asking such questions.
<br>
<b>Nie znoszę wścibstwa, więc przestań zadawać takie pytania. <b><b> <br>
<b>
</td></tr></tbody></table>

How to nest MimeBodyParts in JavaMail (standard email messages)?

I'm trying to send an html email (with a text alternative) that includes an embedded/inline image using JavaMail.
I wanted to see what a properly formatted message looked like so I sent one using gmail with an inline image and below is the original source. It seems as if they are nesting body parts in the message. How can I replicate this EXACTLY using javamail. I found no way to put a Multipart inside of another Multipart.
MIME-Version: 1.0 Received: by 10.50.75.3 with HTTP; Thu, 23 Feb 2012
20:15:34 -0800 (PST) Date: Thu, 23 Feb 2012 20:15:34 -0800
Delivered-To: x#gmail.com Message-ID:
Subject: c From: Foo Bar To: Foo
Bar Content-Type: multipart/related;
boundary=e89a8f3b9b051e124104b9ae03fb
--e89a8f3b9b051e124104b9ae03fb Content-Type: multipart/alternative; boundary=e89a8f3b9b051e123604b9ae03fa
--e89a8f3b9b051e123604b9ae03fa Content-Type: text/plain; charset=ISO-8859-1
plain text content goes here
--e89a8f3b9b051e123604b9ae03fa Content-Type: text/html; charset=ISO-8859-1
--e89a8f3b9b051e123604b9ae03fa--
--e89a8f3b9b051e124104b9ae03fb Content-Type: image/png; name="logo.png" Content-Transfer-Encoding: base64 Content-ID:
X-Attachment-Id: ii_135ad92205fc1ace
iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAh0lEQVR42u3ZsQnAIBBGYVtHShVI
7ViprASXcw8HMCckEGyTkB98xWsE4WvOwnMhBG/tVrGaSOU0+Q5MVhMtdWAVBlY3HCyW+7nlbhqB
TiGAAAECBAhwMqB0AN8ANuUkgQzJvEPy1WP75C5AgAABAgQ4GXATAK4DUP8LOAsD87WGiIJriGj5
AwiiiyDxmymtAAAAAElFTkSuQmCC
--e89a8f3b9b051e124104b9ae03fb--
UPDATE:
Using the standard multipart inline image methods (like those linked to by lechlukasz) produces the following email, not quite what I need:
MIME-Version: 1.0 Received: by 10.236.146.106 with SMTP id
q70mr1894063yhj.0.1330071158663; Fri, 24 Feb 2012 00:12:38 -0800
(PST) Reply-To: Foo Bar Message-ID:
<20cf303bfc80f02cfa04b9b152db#google.com> Date: Fri, 24 Feb 2012
08:12:38 +0000 Subject: please oh please4 From: Foo Bar
To: Foo Bar Content-Type:
multipart/alternative; boundary=20cf303bfc80f02ce704b9b152d6
--20cf303bfc80f02ce704b9b152d6 Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding:
base64
77+9UE5HDQoaDQoAAAANCklIRFIAAAAoAAAAKAgGAAAA77+977+977+9bQAAAO+/vUlEQVR477+9
77+977+977+9Ce+/vSAgDQoQRmFbR0oVSO+/vVjvv73vv70E77+9cw8HMCckEGzvv73vv70ffO+/ vWsE77+9a++/ve+/vXMhBG/vv71W77+977+9SO+/vTTvv70OTFYTLXVgFQZWNxws77+977+977+9 77+9bhrvv71OIe+/vQABAgQIcDLvv710AO+/vQA277+9JO+/vQzvv73vv71D77+977+9Y++/ve+/
vS5A77+9AAECBDgZcBMA77+9A1Dvv70LOAsD77+977+977+977+977+9a++/vWjvv70DCO+/ve+/ vSDvv73vv70p77+9AAAAAElFTkTvv71CYO+/vQ0K
--20cf303bfc80f02ce704b9b152d6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
--20cf303bfc80f02ce704b9b152d6--
You put a Multipart in another Multipart by creating a MimeBodyPart, setting the content of that to the Multipart, and adding that body part to the first Multipart.
You mean something like that:
http://java.sun.com/developer/onlineTraining/JavaMail/contents.html#IncludingImagesWithHTML
Note that you need also modify your html to specify cid:identifier as image src.

MimeMessage Content-Transfer-Encoding issue

Greetings all...
I am hoping somebody can shed me some lights about the issue I am having.
Reading the Javadoc of MimeMessage's getInputStream(), it says "Return a decoded input stream for this Message's content"
However, this is not what I am experiencing. The output is not decoded. For instance, if I have a message a follows
Date: Wed, 24 Feb 2010 11:29:13 +1100
From: xxxxxxxxx
To: xxxxxxxxxxxx
Message-ID: <4B8472D9.5050901#xxxxxxxxx>
Subject: xxxxxxxxxxxxxxxxxx
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------000801030004000206000901"
Content-Transfer-Encoding: quoted-printable
Organization: xxxxxxxxxxxxxxxxxx
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)
This is a multi-part message in MIME format.
--------------000801030004000206000901
Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed
Content-Transfer-Encoding: 7bit
!
--------------000801030004000206000901
Content-Type: text/plain;
name=3D"bla.bla"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
filename=3D"bla.bla"
my.username =3D holly
my.host =3D molly
--------------000801030004000206000901--
Then, assuming that I have an object called 'm' constructed with the above content, then calling m.getInputStream() and dump the output to the screen shows those '=3D' charsets.
What did I do wrong?
If I used QPDecoderStream to decode the output of m.getInputStream() then of course the result will be correct. However, it defeat the purpose, because the Javadoc says getInputStream() returns a decoded input stream.
The issue here is that the message is malformed. You're not allowed to set Content-Transfer-Encoding to quoted-printable on a multipart part:
If a Content-Transfer-Encoding header field appears as part of a
message header, it applies to the entire body of that message. If a
Content-Transfer-Encoding header field appears as part of an entity's
headers, it applies only to the body of that entity. If an entity is
of type "multipart" the Content-Transfer-Encoding is not permitted to
have any value other than "7bit", "8bit" or "binary".
You could probably get the top-level MimeMessage's decoded content stream and instantiate a MimeMultipart from it, but that's just hacking around the fundamental problem of a broken message.

DRM content with MM7 protocol Submit Request

I am creating a SOAP request to MMSC for posting DRM content (.dm file which is a 3gp video).
I am using Saaj API for the same.
The MMSC to which I sending the request to says that they need the SOAP request in the following format as its a 3gpp standards for submitting the SOAP request for a VASP.
POST / HTTP/1.1
Content-Type: multipart/related; boundary="XXX123456789PQR"; type=text/xml; start="<dna_003_mm7type>"
Content-Length: 14636
SOAPAction: ""
--XXX123456789PQR
Content-Type: text/xml; charset="utf-8"
Content-ID: <dna_003_mm7type>
<?xml version='1.0' ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelop/">
<env:Header>
<mm7:TransactionID xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0"
env:mustUnderstand="1">dna_vasp_003</mm7:TransactionID>
</env:Header>
<env:Body>
<SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-3">
<MM7Version>5.6.0</MM7Version>
<SenderIdentification>
<VASPID>2222</VASPID>
<VASID>company</VASID>
</SenderIdentification>
<Recipients>
<To>
<Number>xxxxxxx</Number>
</To>
</Recipients>
<ServiceCode>gold-sp33-im42</ServiceCode>
<LinkedID>123456789</LinkedID>
<MessageClass>Informational</MessageClass>
<TimeStamp>2004-03-12T9:30:47-05:00</TimeStamp>
<EarliestDeliveryTime>2004-03-12T09:30:47-05:00</EarliestDeliveryTime>
<ExpiryDate>8400</ExpiryDate>
<DeliveryReport>true</DeliveryReport>
<ReadReply>true</ReadReply>
<ReplyCharging>true</ReplyCharging>
<replyDeadline>2004-05-12T9:30:47-05:00</replyDeadline>
<replyChargingSize>9198</replyChargingSize>
<Priority>Normal</Priority>
<Subject>News for today</Subject>
<ChargedParty>Sender</ChargedParty>
<DistributionIndicator>true</DistributionIndicator>
<Content href="cid:XYSFGA-135" allowAdaptations="true"/>
</SubmitReq>
</env:Body>
</env:Envelope>
--XXX123456789PQR
Content-Type: multipart/mixed; boundary="company"
--company
Content-Type: application/vnd.oma.drm.message; boundary="drm-boundary-409B8BD9"
Content-ID: base64_4.dm
Content-Location: base64_4.dm
--drm-boundary-409B8BD9
Content-Type: image/jpeg; name=scen2.jpg
Content-Location: scen2.jpg
Content-Transfer-Encoding: base64
/9j/4AAQSkZJRgABAAEAqgCqAAD//gAfTEVBRCBUZWNobm9sb2dpZXMgSW5j
LiBWMS4wMQD/2wCEABUODxIPDRUSERIXFhUZHzQiHx0dH0AuMCY0TENQT0tD
SUhUX3lmVFlyW0hJaY9qcn2Bh4mHUWWVn5OEnnmFh4IBFhcXHxsfPiIiPoJX
SVeCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKC
goKCgoKCgv/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCwEAAwEB
AQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEAACAQMDAgQDBQUEBAAAAX0BAgMA
BBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygp
KjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaH
/9k=
--drm-boundary-409B8BD9--
--company--
--XXX123456789PQR--
Can anyone pls suggest me what I need to do to send different MIME type for a single file attachment. Are there any Java API available to create such requests??? As using SAAJ, I am only to attach one MIME-TYPE for single attachment.
Are you sure you want to deliver .dm encoded files over MMS? DM is used for Separate-Delivery protection method and a handset will need to purchase and download rights in another transaction before content can be viewed. I'm pretty sure that a lot of handset doesn't even support it.
I had more success with MMS and DRM by simply using Forward-Lock protection. To use it, just wrap around a forward lock container in MM7 request.
To generate all this in java see https://stackoverflow.com/a/21663398/3290316

Categories