Existing JSP Pages need to be responsive - java

I need to make the existing JSP pages responsive. I handled the plain HTML files to make it responsive using the bootstrap framework. But with JSP's how it can be achieved effectively as the environment is different. Do I need any extra set up ? any example or link that can help me.
Please suggest me the best way to get it done.
Thanks in advance !!

Related

Accessing HTML elements from java

I need to access HTML elements from my Java program based on the id or className of the element (like getElementByID or getElementsByClassName). I also need to be able to click a few buttons on the page.
Main Points:
I am creating a desktop application. It is not a web app.
I need a browserless solution
My code needs to auto fill a form and submit it without opening a page.
Are there any libraries out there that could suit my needs, or could I achieve this in plain Java code? If my question isn't clear please let me know and I will try to explain it in a better way. Thank you.
Selenium is a library used for scraping html elements using java. It is often used for testing. There is another library called Vaadin. It is used for doing front-end work on the back-end using java. It is similar to Java Swing but used on the web. Hope this helps!

Is it advisable to use 'include' tag of jsp for setting the general structure of the website?

I am making a website with around 20 pages in it. Now almost all the pages have same general layout like the menu bar, header, footer etc. I've made a jsp page which contains this common contents and then with the help of 'include' tag I'm using it for the other pages. So is it advisable to follow this technique? Kindly inform me about the pros and cons of using this technique.
Thanks in advance.
Remember that with each #include tag,the whole jsp thing will be converted to a servlet and then it will work as required HTML format as compiled by the browser. So there is no doubt that for a large application it will create unnecessary performance issue.
Instead of doing this you may use iframe tag which is now widely used in web development.
You may modify the iframe source code as u want........
So it's totally depends on which way you want to proceed and your application context.there is no fixed rule that you must have to use this or that technoque

jsp, can't find source of css property

This may be a tricky question because I can't give much detail,
I'm working of legacy code on a big project (in jsp) and I came across a "styleid = product".
It changes quite a lot of things when I remove it, but I can't seem to find it in any of the CSS files, there are properties like "tdproduct" and "thproduct" but I can't seem to find any connection.
Can anyone give me an indication of other places I might need to look for this (except .css files).
thanks in advance
Can you load the page in firefox/chrome browser?
If so you can see the generated source code.
Since JSP is a server side technology that generates some dynamic content, its also possible that the CSS will be also generated dynamically.
Theoretically it can be JSP itself, the CSS and even Java Script :)
Good luck!
Hope this helps
css are dynamically loaded when your page is loaded. your style classes can also be defined in the jsp that you are including in the parent jsp.
open the page in firefox and use firebug to view the styles loaded. You can locate where your style is loading from.

display stream of images without refreshing the webpage to give user a video like experience

I have a series of images generated at the servlet. I want to show the images on a JSP page.
I want to show the images in a way that the JSP page is not refreshed only the image gets refreshed and get replaced by the new one. I thought of doing it with the help of applet or AJAX. But I am still looking for some convenient way of doing it. can anyone suggest some way of doing it? Any help is much appreciated.
Thanks in advance.
I'd go with JavaScript if I were you. It should be pretty simple to have a list of images and set a timer to change the source of the image tag every second (or whatever). You probably don't even need "real" AJAX for that... just changing the attributes in the DOM.
Admittedly it may not look great if the images take a while to load - you might want to have some cunning mechanism to load all the images beforehand, and then change which one is visible at any one time, or something like that. It still shouldn't need AJAX or an applet though.
I'm not sure I'd describe this as a "video-like" experience - more like a slide-show - but it should be okay. If you want real video, use video :)
There are a lot of simple jQuery image slideshow libraries that are easily added to your page and can add some great effects - for example:
http://nivo.dev7studios.com/#usage

Swing components inside HTML

Does anybody know of a pure java (ar at least cross platform) open source component/library which displays HTML which can contain swing components inside it?
All I could find were either abandoned or incomplete.
I am asking because I'm thinking about trying out approach to do use this combination for creating desktop application.
EDIT:Seems like this question is missunderstood, so let me clarify it. I basically want to create desktop application in the similar way as web. Idealy I would like browser to serve as an UI layer. That browser should allow me to embed my own compoents, eg to be able to use JTextField instead of <input type="text">.
Since I don't know of such easily usable browser, I was asking for a html component which will let me do it. I hop the question is clearer right now.
JEditorPane already supports what you want to do. It can render HTML (pretty crappily, I'll admit) and you can embed Swing components in that HTML using the <object> tag. Here is a blog post that demonstrates this technique: http://weblogs.java.net/blog/aim/archive/2007/07/index.html
Otherwise, I don't think you have a lot of options.
I think the question is the other way around or, better, goes further than using JTextPane. As I understand the question: Marko needs a Java component that can display HTML and additionally is able to contain further Swing components. Say, there should be a new tag
<swing jclass="MySwingComponent" />
which would render that MySwingComponent class. Not sure, maybe it would also be okay to have a HTML-able Swing component that can embed further applets?
And no, I don't know of such a thing. Sorry.
JavaFX maybe?
check out xhtmlrenderer: https://xhtmlrenderer.dev.java.net/
You will have to work wit it to get it to do all you want.
I thought Google Web Toolkit allowed you to write a UI in terms of Java/Swing. It would then convert it to JavaScript. Maybe that's what you're looking for.

Categories

Resources