• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 02:10
CET 08:10
KST 16:10
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Rongyi Cup S3 - RO16 Preview3herO wins SC2 All-Star Invitational10SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0
Community News
Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)19Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7
StarCraft 2
General
Oliveira Would Have Returned If EWC Continued StarCraft 2 not at the Esports World Cup 2026 Stellar Fest "01" Jersey Charity Auction PhD study /w SC2 - help with a survey! Rongyi Cup S3 - RO16 Preview
Tourneys
Arc Raiders Cat Bed Map Guide OSC Season 13 World Championship $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) $70 Prize Pool Ladder Legends Academy Weekly Open! SC2 All-Star Invitational: Jan 17-18
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone
Brood War
General
Gypsy to Korea [ASL21] Potential Map Candidates Which foreign pros are considered the best? BW General Discussion BW AKA finder tool
Tourneys
Azhi's Colosseum - Season 2 [Megathread] Daily Proleagues Small VOD Thread 2.0 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Current Meta Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Game Theory for Starcraft
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Stormgate/Frost Giant Megathread Beyond All Reason Awesome Games Done Quick 2026!
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread NASA and the Private Sector Canadian Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Navigating the Risks and Rew…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1276 users

The Big Programming Thread - Page 614

Forum Index > General Forum
Post a Reply
Prev 1 612 613 614 615 616 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 15 2015 21:03 GMT
#12261
On April 15 2015 13:41 FFGenerations wrote:
ok well i've given up trying to make it work this way for now. i sort of understand what you've been saying earlier about the autogenerated thing being fucked up. what you wrote totally flew over my head before, but you kept railing on about it until i started to understand. thanks all, you've been brilliant!

will move on to trying to parse it myself instead

Good that you're moving in the right direction .

Just a couple things so you don't get overly dissuaded. There's nothing inherently wrong with using auto-generated code, and in fact a lot of major frameworks will have you relying a bit on them (C# with ADO.NET comes to mind). The important thing is to understand why you're using an auto-generator, and how actually interact with it.

Overriding ToString() methods is also a valid option in many cases, and returning the main identifier for an object like a Name is definitely a good time to do it. Of course, in this circumstance it would be a band-aid solution, because inevitably you'll want other information from you objects, and you'll be right back to the same problem you started with.

Finally, parsing text may seem like a massive undertaking at first, but it's something you will be dealing with eventually if you're a programmer of any kind, so it's definitely something worthwhile to learn. Luckily for you, you're dealing with XML, which is basically designed to be parsed easily.
Average means I'm better than half of you.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-15 22:55:38
April 15 2015 22:33 GMT
#12262
i found a pretty crazy good tutorial



i done the basic one first which also shows it being done with Lists then was wondering why the fuck my nested xml wasnt working and then found the person had just uploaded this one, thank god

so ..... the next thing i'm going to find out is how "deep" into the xml file i need to go to get the data i want i guess, or how far i can simplify it before it fucks up on me. i tend to lean towards it being easy now but i might end up having to look at a plugin that jumps to the parts i want, or something, which would be annoying :D since i have 5 days left lol

the xml file starts off something like this

<ann>
- <anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<related-prev rel="related to" id="13312" />
- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>


so thats like

<ann>
<anime> (use @XmlValue here maybe to grab 'anime id' and 'anime name'? need to check what it does exactly)
<info></info>
<info></info> (how to deal with multiple infos? maybe @XmlValue will straight up work here too to grab 'info src'. or maybe the parser will return a List of infos in this case)
.....
</anime
</ann>
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:49:40
April 16 2015 01:32 GMT
#12263
hi, im a bit stuck on this bit

so from what i can gather Ann (top class) returns as a list of Anime objects

the Anime class should have multiple attributes though: name, id and List of Info objects

FIXED
+ Show Spoiler +

so right now i have it looking like this:

public class Anime {

private String id;
private String name;
private List<Info> infolist;
...
public List<Info> getInfolist() {
return infolist;
}

public void setInfolist(List<Info> infolist) {
this.infolist = infolist;
}
...
public Anime(String id, String name, List<Info> infolist) {
this.infolist = infolist;
this.id = id;
this.name = name;
}


this looks different to the Ann class where i have

public class Ann {

private List<Anime> Ann = new ArrayList<Anime>();

@XmlElement(name="anime")
public List<Anime> getAnn() {
return Ann;
}

public void setAnn(List<Anime> Ann) {
this.Ann = Ann;
}


after unmarshalling the xml file into Ann, i am able to perform

for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

this works.

however i am struggling to be able to access the Info list that should be in the anime class.

i guess the question is, how do i correctly set a list of Info as an attribute of the anime class

Anime class did look similar to Ann to begin with, as below, but i thought maybe that was wrong


public class Anime {

private String id;
private String name;
private List<Info> Anime = new ArrayList<Info>();
...
public Anime(String id, String name) {
this.id = id;
this.name = name;
}



i reverted the code back to how it was in the tutorial (where the topmost class had only 1 attribute so i thought it might look different).

then in my unmarshaller i added a 2nd for loop to try to access the Info list , somehow i got the right syntax


for (Anime anime : ann.getAnn()) {

System.out.println("ID: " + anime.getId());
System.out.println("Name: " + anime.getName());

for (Info temp : anime.getAnime()){
System.out.println("Info: "+temp.getSrc());
}
}
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 01:53:34
April 16 2015 01:47 GMT
#12264
+ Show Spoiler [you fixed it] +
private List<Info> Anime = new ArrayList<Info>();

Why is the name of the variable Anime? Do you even need this field? Each Anime having a list of "Info" (whatever that means) seems pretty stupid in the first place. If you need more fields you can create them and call them things that actually make sense. You'd want to add fields for say release date or author rather than creating a list of Info.


I really dislike the idea of this Info class, but if it works then I won't rain on your parade.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 01:59:28
April 16 2015 01:53 GMT
#12265
i'm using Info because its one of the XML tags... it occurs dozens of times for each anime entry with just random different info in:

- <info gid="1527892938" type="Picture" src="http://cdn.animenewsnetwork.com/thumbnails/fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200">
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-fit200x200/encyc/A16547-1527892938.1417492374.jpg" width="139" height="200" />
<img src="http://cdn.animenewsnetwork.com/thumbnails/hotlink-max500x600/encyc/A16547-1527892938.1417492374.jpg" width="174" height="250" />
</info>
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
etc


so i'm currently saving everything in an info tag into an Info object


@XmlRootElement (name="info")
public class Info {

private String src;

@XmlAttribute(name="src")
public String getSrc() {
return src;
}


and taking the @XmlAttribute from each info entry (if it exists) (only 1 exists per anime and i only need the 1, so that's handy) and accessing it with info.getSrc

right now i'm getting....

[image loading]

which is basically "HOLY FUCK I DONE IT AND SO FAST LOL OMFG TNX TUTORIAL also tnx brain and planning on paper lol"

btw is it normal for netbeans to ramp up to 1,300,000 memory lol

look lol

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 02:05:16
April 16 2015 01:58 GMT
#12266
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


Well each of those Info objects is at least 20 bytes and then you have a ton of them per parse so...

catch (Exception e)


My eyes are bleeding. I guess if you're just going to print the message then maybe it doesn't matter, but ^_^
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 02:36:54
April 16 2015 02:05 GMT
#12267
what i would delete that shit but it probably goes all red

i'm going to use the data to populate a webpage frontend for the user and also save it to a local database or do something else with it

i guess my next task is to go figure out the API get request so it doesn't look like a complete hackjob




i have a sort of interesting question .... how would i describe what this is doing in non-retard terms? for example i am trying to describe it like:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 02:47 GMT
#12268
I'm pretty bad at jargon too, so can't really help you there . It's basically a practice thing.

Also, you seem to over-complicating things by having an Info class. If the data is stored like this:
<anime id="16547" gid="1838091909" type="OAV" name="Kono Danshi, Sekika ni Nayandemasu" precision="OAV" generated-on="2015-04-14T20:49:39Z">
<info gid="2071101469" type="Main title" lang="EN">Kono Danshi, Sekika ni Nayandemasu</info>
<info gid="367748411" type="Alternative title" lang="JA">この男子、石化に悩んでます。</info>
<info gid="742528363" type="Genres">supernatural</info>
<info gid="3133430704" type="Themes">yaoi</info>
<info gid="1492846673" type="Running time">26</info>
</anime>


Then you should be parsing the type field in the info tags, and then pass the value into a variable in the Anime class. Basically, your class should look something like this:
class Anime{
private string title;
private string altTitle;
private string genre;
private List<string> themes; //assuming >1 theme is possible, otherwise just a single string
private double runTime;
}
Average means I'm better than half of you.
phar
Profile Joined August 2011
United States1080 Posts
April 16 2015 03:05 GMT
#12269
^^ strongly agree with using separate fields for things instead of just generic repeated info

You can heave a repeated info for unknown info tags if you want, but try to get more stuff parsed in up front, it's more useful.
Who after all is today speaking about the destruction of the Armenians?
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2015-04-16 03:07:43
April 16 2015 03:06 GMT
#12270
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.
I'll always be your shadow and veil your eyes from states of ain soph aur.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 03:21:46
April 16 2015 03:19 GMT
#12271
i'm not sure if that is possible

the way i am doing it is

look at @XmlRootElement (name="info")
look at @XmlAttribute(name="src")
save this


if there is an xml parser functionality that lets me check for Picture inside Infos then take the corresponding SRC from that Info and put it straight into Anime then sure....but i don't know if @XmlAttribute or @Something exists to do that

if anything there might be a plugin that lets you do that, like it autoscans the document and returns X for your nomatter where X is located...........

there is no fucking way i'm getting into that though :D i've got 4 days to finish this and then 4 days to do 2 other major assignments . edit: unless there is @functionality that just does that.............
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
April 16 2015 03:23 GMT
#12272
On April 16 2015 12:06 Blitzkrieg0 wrote:
Show nested quote +
On April 16 2015 11:05 FFGenerations wrote:

"custom parser that unmarshalls desired data from my sample nested xml file into objects with inheritance " <- this last bit, how should it be described? i want to indicate that the classes are connected and also use Lists as attributes.....

silly question but maybe you wanna answer it . i'm really bad at using terminology . i guess i could phrase it "custom parser that unmarshalls desired data from my sample nexted xml file into objects using inheritance and lists as attributes"


Well you didn't actually end up using inheritance so that would just be a lie. We thought you needed inheritance because you had Anime and Manga classes before, but the Manga class disappeared so you don't need/aren't using inheritance.

The application services client anime requests by acquiring the information from <webservice> and displaying them in a user friendly manner. How this works under the hood is irrelevant unless that is what you're supposed to be describing.


i was just describing the "prototype version" for when i have to write about it and sound mildly technical or whatever
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
WolfintheSheep
Profile Joined June 2011
Canada14127 Posts
April 16 2015 03:29 GMT
#12273
Well, can't help you with the specifics because I haven't used JAXB before. That said, this is the part where you learn that your power to Google is what makes you a programmer :D.
Average means I'm better than half of you.
ArchmageKruzer
Profile Joined August 2013
64 Posts
April 16 2015 03:43 GMT
#12274
So a couple of my friends and I want to make an IOS game. Currently we're writing the code in Java and then we're gonna import it into IOS. My question is is this a good idea, and if so, do you have any tricks and stuff to make the import easier, since there are probably gonna be like a million things going wrong once we do it.
Also, i've been poking around for engines, and 5 mins of google got me to the Unreal engine, which seems pretty OK. Any engine suggestions for IOS games, and tips/tutorials on how to use them?
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 13:17:07
April 16 2015 04:30 GMT
#12275
+ Show Spoiler +
(ignore this bit)
+ Show Spoiler +
so apparently you don't need to use REST web services, you can just have

URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~neon genesis" );

Ann ann = (Ann) ums.unmarshal(url);

and it does the get request and puts it straight into your parser. wtf. that is insane
i just shaved like 40 years off my life


i think i move on to figuring out how to make it into MVC now with a basic web frontend and then add a database functionality and then add jquery stuff



question about what i do next:

am i supposed to have the anime classes as managed java beans or can i keep them as they are and just print the data to a jsp page via a servlet controller?

ive been fucking around for a while and ended up with an insane mess and getting no error but it just fails to run with no error specification . at one point i tried to add bean annotations ontop of the xml annotations but it gave me a frowny face and i backed off for the time being

this is what i've got in my head so far:
1) jsp frontend page that takes the user's search string in a form
2) servlet page that takes this and passes it to my service class
3) the service class does GET request and parses the response into the anime objects
4) but then how do i access this data ? does it need to be turned into a java managed bean? can i access it directly from the jsp page? does it need to go through the servlet controller?

ill come back in 8 hours or whatever after i slept

have been trying random stuff but there's tons of stuff to try and that's before i even go to one of the super heavy tutorials .

edit: maybe i make session facade bean from the Ann java class and then use that to do stuff. if it lets me annotate it



OK here is what i've got so far. it runs , time-outs for about 9 seconds, then displays the HTML ("end") ie it doesnt display the object data

ControllerServlet.java
+ Show Spoiler +


ControllerServlet.java

package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

@EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB.Unmarshalling("evangelion");

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}


AnnJAXB.java
+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public static void Unmarshalling(String searchString) {
try {

JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );

Ann ann = (Ann) ums.unmarshal(url);


} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}



when i remove the line AnnJAXB.Unmarshalling("evangelion"); it runs and displays the html instantly, so that bit there is causing it to time out and return nothing from it.

the obvious problem is in AnnJAXB at the line

Ann ann = (Ann) ums.unmarshal(url);

for this it says Variable ann is not used

the other bit that looks weird is
 @EJB
private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann = new Ann();
bit


posted to stackoverflow, easier to read http://stackoverflow.com/questions/29674404/mvc-object-method-and-serlvet-structure-help-in-java-please


i tried changing AnnJAXB Unmarshall to return an Ann instead of being static void method. i managed to get it to work eventually but its still hanging like previous version then not displaying the object data.

controllerservlet
+ Show Spoiler +


package main;

import entities.Anime;
import entities.Ann;
import entities.Info;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
*
* @author J
*/
@WebServlet(name = "ControllerServlet", urlPatterns = {"/ControllerServlet"})
public class ControllerServlet extends HttpServlet {

// @EJB
// private AnnJAXB annJAXB = new AnnJAXB();

@EJB
private Ann ann;

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ControllerServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ControllerServlet at " + request.getContextPath() + "</h1>");

AnnJAXB an = new AnnJAXB();
try{
an.Unmarshalling("evangelion");
}catch(Exception e){}

for (Anime anime : ann.getAnn()) {

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");
}
}



annjaxb

+ Show Spoiler +


package main;

import entities.*;
import javax.xml.bind.*;
import java.io.*;
import java.net.URL;
import java.net.MalformedURLException;
import javax.ejb.Stateless;

@Stateless
public class AnnJAXB {

public Ann Unmarshalling(String searchString) throws JAXBException, MalformedURLException {


JAXBContext jc = JAXBContext.newInstance(Ann.class);
Unmarshaller ums = jc.createUnmarshaller();
URL url = new URL( "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?title=~"+searchString );


Ann ann = (Ann) ums.unmarshal(url);

return ann;
}
}



i have no words

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Manit0u
Profile Blog Joined August 2004
Poland17614 Posts
April 16 2015 19:25 GMT
#12276
On April 16 2015 10:53 FFGenerations wrote:
btw is it normal for netbeans to ramp up to 1,300,000 memory lol


*reads the word "netbeans"*

*averts his eyes*
Time is precious. Waste it wisely.
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 22:38:54
April 16 2015 22:38 GMT
#12277
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-04-16 23:06:49
April 16 2015 23:06 GMT
#12278
On April 17 2015 07:38 FFGenerations wrote:
OK so the animenewsnetwork is online again now so I can finally test what I was doing all that time. It loads without timing out but nothing in the For loop , neither the html nor the Ann attributes, are displayed.

I posted a well-formatted version to http://stackoverflow.com/questions/29687169/accessing-an-instance-of-an-object-from-a-serlvet-in-java-web-application

If you could have a glimpse that would be awesome :/

I just woke up so gonna take another look in a min


Are those your only 3 classes in SO. It's kind of hard to troubleshoot code without being able to run it. Did someone already talk to you about possibly putting your stuff on github or something if you want more help?

Edit: Definitely not your only 3 classes. See question above
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:16:17
April 16 2015 23:15 GMT
#12279
hey dude, here is a zip file with the project (if google drive lets you share zipped code)

https://drive.google.com/file/d/0BzIvzoW04fGQbUdMT3RYVXN5ODA/view?usp=sharing


i got stuck trying to get git to work a while back and havent tried to use it since. i will sort that out sometime
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
FFGenerations
Profile Blog Joined April 2011
7088 Posts
Last Edited: 2015-04-16 23:34:05
April 16 2015 23:26 GMT
#12280
STOP I FIXED IT HOLY FUCKING CHRIST


I changed the loop to say:
+ Show Spoiler +

 for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {


and removed

 annj.Unmarshalling("evangelion");


so it looks like


try{
for (Anime anime : annj.Unmarshalling("evangelion").getAnn()) {

out.println("<h1>Loop1</h1>");

out.println("<h1>ID: " + anime.getId() + "</h1>");
out.println("<h1>Name: " + anime.getName() + "</h1>");

for (Info temp : anime.getAnime()) {
if (temp.getSrc() != null) {
out.println("<h1>Info: " + temp.getSrc() + "</h1>");
}
}
}}catch(Exception e){}

out.println("<h1>End</h1>");
out.println("</body>");
out.println("</html>");


pic

+ Show Spoiler +

[image loading]
Cool BW Music Vid - youtube.com/watch?v=W54nlqJ-Nx8 ~~~~~ ᕤ OYSTERS ᕤ CLAMS ᕤ AND ᕤ CUCKOLDS ᕤ ~~~~~~ ༼ ᕤ◕◡◕ ༽ᕤ PUNCH HIM ༼ ᕤ◕◡◕ ༽ᕤ
Prev 1 612 613 614 615 616 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 3h 50m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 224
StarCraft: Brood War
Shuttle 139
Mong 102
Hm[arnc] 65
Shine 39
ZergMaN 36
Mind 30
NotJumperer 21
Bale 9
Backho 8
Dota 2
NeuroSwarm162
League of Legends
JimRising 788
C9.Mang0455
Super Smash Bros
Mew2King126
Other Games
summit1g4038
XaKoH 0
Organizations
Other Games
gamesdonequick911
StarCraft: Brood War
UltimateBattle 76
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• practicex 31
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Laughngamez YouTube
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Lourlo1499
• Stunt467
Other Games
• Shiphtur245
Upcoming Events
RongYI Cup
3h 50m
Clem vs ShoWTimE
Zoun vs Bunny
Big Brain Bouts
9h 50m
Percival vs Gerald
Serral vs MaxPax
RongYI Cup
1d 3h
SHIN vs Creator
Classic vs Percival
OSC
1d 5h
BSL 21
1d 7h
RongYI Cup
2 days
Maru vs Cyan
Solar vs Krystianer
uThermal 2v2 Circuit
2 days
BSL 21
2 days
Wardi Open
3 days
Monday Night Weeklies
3 days
[ Show More ]
OSC
3 days
WardiTV Invitational
4 days
WardiTV Invitational
5 days
The PondCast
6 days
Liquipedia Results

Completed

Proleague 2026-01-20
OSC Championship Season 13
NA Kuram Kup

Ongoing

C-Race Season 1
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Escore Tournament S1: W5
Rongyi Cup S3
Underdog Cup #3
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025

Upcoming

Acropolis #4 - TS4
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Nations Cup 2026
Tektek Cup #1
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.