aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes java code compatibility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "java code compatibility" Watch "java code compatibility" New topic
Author

java code compatibility

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
How to make java code compatible to all browsers?
I have got 50-60jsps and java scripts... currently it works only for IE.
Can we handle the compatibility using javascript code??
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Well, JSP only generates the HTML. If you need certain syntax or whatever for certain browsers,
then you could get the request parameters for browser signature and perform as such.

I would personally let this up to the browser javascript itself, do not generate js via the JSP.

WP
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2854
    
  11

I assume most of your compatibility issues are with JavaScript, not JSPs, so I'm going to move this to our HTML, CSS, and JavaScript forum. As William pointed out, JSP code runs on your server, not the browser, though what it outputs could have browser compatibility issues.

Unfortunately, there's not a simple answer to JavaScript compatibility among different browsers. IE has been notoriously bad at sticking to standards, so anything targeting it didn't run well on other browsers. Professional web developers used to go insane trying to trick different browsers into behaving consistently, and their sad experiences are documented at length in various texts and web sites.

However, there are a couple simple things you can do:

1. Officially drop support for IE 6. Microsoft's adherence to standards improved markedly starting with IE7. IE6 was a disaster everyone should be ready to close the page on.
2. Use JQuery. JQuery takes different browsers into account and knows all the tricks to make them behave. Plus it's so much easier to use than raw JavaScript.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Please be precise when talking languages, there's Java and then there's JavaScript, which have nothing at all to so with each other. Be sure not to use these terms interchangeably.

So which are you actually asking about?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Greg Charles wrote:1. Officially drop support for IE 6. Microsoft's adherence to standards improved markedly starting with IE7. IE6 was a disaster everyone should be ready to close the page on.

In fact, Microsoft itself no longer supports IE6 -- no one else should either.

2. Use JQuery. JQuery takes different browsers into account and knows all the tricks to make them behave. Plus it's so much easier to use than raw JavaScript.

Very, very much this. Life is too short to write JavaScript without jQuery.
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Thanks all for the inputs.sorry for framing the question in a bad way.we have huge code in struts,hibernate.it is working only in IE and it shd work in al browsers. We shd finsh this EOD so i am looking to quickly finish this.couldnt find anything ready on net and i hav never tried jquery.how should i progress?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10210
    
166

Pradeep Adibatla wrote:how should i progress?


As a first step, clearly explain with an example on what exactly doesn't work. Otherwise the question is too vague to even guess whether it's an issue with the way it's implemented in your application or something else.

[My Blog] [JavaRanch Journal]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4750
    
    7

Pradeep Adibatla wrote:Thanks all for the inputs.sorry for framing the question in a bad way.we have huge code in struts,hibernate.it is working only in IE and it shd work in al browsers. We shd finsh this EOD so i am looking to quickly finish this.couldnt find anything ready on net and i hav never tried jquery.how should i progress?

I'm assuming "EOD" means End-Of-Day and not End-Of-Decade. One of your best bets probably is JQuery as others have already advised. See http://api.jquery.com/jQuery.support/
Bear already alluded to this but the fact that your application uses Struts and Hibernate has nothing to do whatsoever with the generated HTML not working in IE. That said, you will probably end up changing JSPs and .js files to include hacks for supporting IE in the generated HTML.

One protocol-related comment: Please try to spell out words fully. "shd", "al", "finsh", and "hav" may be easier for you to type but it's more difficult for people to read than "should", "all", "finish", and "have". Unless you're accessing these forums using a cellphone with no QWERTY keyboard, it borders on the impolite to make people work harder than they need to just to try to help you out. Granted, you did type the full words in some spots but a little effort in making sure your posts are readable will go a long way in getting an answer.

Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java code compatibility