Not applying css in struts application while using pretty url - java

I am doing web application in struts using jsp.I used pretty url's.[i.e.elimination of .do,? ]
When i enter simple url like ->http://localhost:8084/project Name/page.jsp it will show that page with css applied.
But when i enter another page like->http://localhost:8084/project Name/page/8 it will not show the page with the css applied.
Why css is not applying what changes should be made in web.xml file

Not a good practice to use the URL's directly in struts , that does not truly go with mvc2 pattern , always use forward action for this type of work.
Using a central relative css is the best practice .

Related

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

Does Spring MVC 3.x support partial views (html/jsp) like that of ASP.NET MVC3/4?

Q1: Does Spring or any opensource java UI framework support partial views like that in asp.net mvc?
For example in my main index.html (or _layout.cshtm per asp.net mvc3 spec)
I would have the folllowing code:
<span id="logindisplay">#Html.Partial("_LogOnPartial")</span>
where #Html is a helper to display a partial view for _LogonPartial.cshtml which just injected it's html view contents into the page?
Q2: If this is supposed If I want to display a bunch of partial views it would be helpful to display them concurrently in parallel to improve performance. Very similar to what linkedin is doing using dust and fizzy? http://engineering.linkedin.com/profile/engineering-new-linkedin-profile
Q3: Is fizzy available as open source like that of dust?
If you want to include content of a page into another page, by adding some code on the page itself, you should compare asp with jsp, not ASP.NET MVC* with JEE - Spring MVC
So, an equivalent to <span id="logindisplay">#Html.Partial("_LogOnPartial")</span> on a jsp would be one / all of the following
On your jsp, include content from another jsp using <%# include file="../includes/inner-content.jsp" %>. This is what is called a static include. The source of the included jsp is included and made part of the parent jsp, before the jsp is compiled. If you use an IDE, it will check to ensure the included jsp does infact exist at the path specified, relative to the location of the jsp in which you are adding the include. Technically this is a JSP Directive. The jsp being included could just be a fragment, and not addressable from the outside world (could be hidden inside WEB-INF)
You can also use what's called a Dynamic include <jsp:include page="someJSP.jsp" />. In this case, the included JSP should be addressable from the browser and should be capable of being rendered independently. When the server is executing the servlet to render the parent JSP, it stops when this tag is seen, and starts executing the servlet for the included jsp, the output obtained from the inner jsp execution is then merged to the output of the parent jsp, and processing of the parent jsp is resumed.
A third option would be to use Core JSTL taglib's <c:import url=""/>. This works just like option 2 above, except it also allows you to import a page / content from a url that lives outside your application. Basically you can mention a path to a jsp, or relative URI to a servlet mapping in your application, or a URL to an external page.
Now, I suspect this is not really what you want to do, if you are comparing with what Linkedin is doing. You want to mashup content from sources in your own application, and compose your page. You also want to do this in an asynch manner so as to keep load times in check. In this case, you HAVE to use JavaScript and Ajax. All the mechanisms described above are for server rendered pages (All HTML is created before the page is rendered in the browser). Just like #HTML. You need to create a simple framework / use an existing one, where once a page loads, it fires asynch ajax calls to the server to get content for specific areas on the page and renders the returned HTML in those specific areas.
Hope this helps.
Do let me know if I've misunderstood your question.

Firebug kind of library/control (php/java/.net) to use in my application

Is there any PHP/.NET/Java library that I can use in my application to get final CSS styles applied to elements of a web page (after css and js are executed). For example I want to get text color of the <p class="summary"> in a loaded HTML page.
Is there a firebug kind of library/control (php/java/.net) to use in my application. No UI is neccessary though.
Essentially, you need a web browser for this. You may want to look into embedding options of web browsers (UI-less, I guess), or you could go the easy route and implement it as e.g. a Chrome or Firefox extension right away; essentially running inside the browser and having the browser do all the parsing and CSS work for you.

Regular HTML pages on Struts 2 Spring Framework

I personally do not have much experience working in jsp and struts2 tomcat server but I have a small task that I have to deal with a server in production. I looked at info on the internet for two nights but seems like i can't get the answer.
What I want to do is to open some static simple html pages pop-up from the jsp pages that already exist. Those jsp pages are currently located at /webapps/WEB-INF/tld/mainPage/indexMainPage.jsp
what I did was:
make some javascript functions so that when they click a button, i open a pop-up
function btn_openPopUp()
{
window.open("../popUp/test.html");
}
and put the test.html page at /webapps/WEB-INF/tld/popUp/test.html
The pop-up part works fine as it is just simplye javascript, but test.html is not displayed.
Struts Problem Report
Struts has detected an unhandled exception:
Messages:
There is no Action mapped for namespace / and action name test.
I have been looking at info online, and everything about struts is action based. Is there anyway I can open a page like on a regular server?
Pages under WEB-INF are not directly accessible to clients; put such pages under the root somewhere.
They can still be in sub-directories if it makes sense, just not under WEB-INF. If they must be under WEB-INF for some reason (which makes no sense for non-JSP pages) they can be streamed through an action like any other file--bit that'd be weird for HTML pages.

How Can I rewrite SEO friendly URL on STRUTS?

We have a website which is coded Java with Struts Framework. The WebSite's Urls are not seo friendly. All of them are like below
../buyerApplication.do&companyId=2323
Now We want to make these URLs SEO friendly and I searched and found these solutions:
tuckey.org/urlrewrite : but i don't rely on this system.
adding
title end of link after '&' such as
"../newsId=33233&does-art-in-the-city-equal-art-for-the-city"
: In this solution I am not sure it
works well.
I am waiting your sugestions to solve this problem best.
I actually used URLRewriter (http://tuckey.org/urlrewrite/), which you referenced in your original question. It was very easy to set up and filled my needs perfectly.
To the point, you need a Filter for this.
If you want to keep your existing application's architecture, you'll need to define and create a set of rules to convert unfriendly urls to friendly urls and let the filter convert it and forward the request to the unfriendly url.
If there is no means of modifying an existing application but you want to create a new application based on this idea, you could consider to having a single page controller which translates the HttpServletRequest#getPathInfo()/getRequestURI() to execute the appropriate action class (command pattern) and finally forward the request to the appropriate JSP page. Not sure how that would fit into Struts as I haven't worked with Struts previously.
For what it's worth, you can also look at the REST plugin http://struts.apache.org/2.x/docs/rest-plugin.html, which amongst other things will make your URLs more friendly

Categories

Resources